Building a fully independent wireshark dissector module in C++ - c++

I want to build an independent Wireshark dissector module that I can recompile and use on various platforms like Android (using NDK).
To do this, I've selected some of the Wireshark source files and applied my changes. Now I have a full C and C++ module compiled with the C++ compiler in the Qt ide and in Ubuntu, which itself consists of a series of .h and .cpp files (with my custom changes) and a series of .h and .cpp files which I have written from scratch.
This module links to a large number of Wireshark header files as well as three Wireshark libraries, namely libwireshark.so and libwiretap.so and libwsutil.so, which I put the required header files in a folder and libraries in a another folder and set them alongside the project and the project is executed correctly. Since this module is based on Wireshark, it also has some dependencies on glib and some other libraries that are already available in Ubuntu. These libraries include the following with the command ldd myApp.
linux-vdso.so.1 (0x00007ffcaccf8000)
libwireshark.so.7 => /usr/local/lib/libwireshark.so.7 (0x00007f7d6f561000)
libwsutil.so.6 => /usr/local/lib/libwsutil.so.6 (0x00007f7d6f33e000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f7d6efb5000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f7d6ed9d000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f7d6e9ac000)
liblua5.2.so.0 => /usr/lib/x86_64-linux-gnu/liblua5.2.so.0 (0x00007f7d6e77a000)
libgcrypt.so.20 => /lib/x86_64-linux-gnu/libgcrypt.so.20 (0x00007f7d6e45f000)
libgnutls.so.30 => /usr/lib/x86_64-linux-gnu/libgnutls.so.30 (0x00007f7d6e0fa000)
libkrb5.so.3 => /usr/lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f7d6de24000)
libk5crypto.so.3 => /usr/lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f7d6dbf2000)
libwiretap.so.5 => /usr/local/lib/libwiretap.so.5 (0x00007f7d6d90f000)
libgmodule-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgmodule-2.0.so.0 (0x00007f7d6d70b000)
libglib-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f7d6d3f5000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f7d6d1d8000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f7d6ce3a000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f7d6cc1b000)
/lib64/ld-linux-x86-64.so.2 (0x00007f7d743f9000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f7d6ca17000)
libgpg-error.so.0 => /lib/x86_64-linux-gnu/libgpg-error.so.0 (0x00007f7d6c802000)
libp11-kit.so.0 => /usr/lib/x86_64-linux-gnu/libp11-kit.so.0 (0x00007f7d6c4d3000)
libidn2.so.0 => /usr/lib/x86_64-linux-gnu/libidn2.so.0 (0x00007f7d6c2b6000)
libunistring.so.2 => /usr/lib/x86_64-linux-gnu/libunistring.so.2 (0x00007f7d6bf38000)
libtasn1.so.6 => /usr/lib/x86_64-linux-gnu/libtasn1.so.6 (0x00007f7d6bd25000)
libnettle.so.6 => /usr/lib/x86_64-linux-gnu/libnettle.so.6 (0x00007f7d6baef000)
libhogweed.so.4 => /usr/lib/x86_64-linux-gnu/libhogweed.so.4 (0x00007f7d6b8bb000)
libgmp.so.10 => /usr/lib/x86_64-linux-gnu/libgmp.so.10 (0x00007f7d6b63a000)
libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f7d6b436000)
libkrb5support.so.0 => /usr/lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f7d6b22b000)
libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f7d6b027000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f7d6ae0c000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f7d6ab9a000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f7d6a992000)
As I said at the beginning of my question, my goal is to make this module completely independent and capable of being recompiled and used on other platforms like Android. Now, my question is that is this independence arises by putting all these libraries on the top alongside the project? If not, what is the solution? Is there a similar program to get help (like Signal guru but this is not open source)?

Related

execute binary using google protobuf error

I'm developing an C++ application under Ubuntu 16 using google protobuf. When I compile and run at the same machine, it works fine, but when I try to run it at another Ubuntu 16 I get the following error
./APP: Symbol `_ZTVN6google8protobuf11MessageLiteE' has different size in shared object, consider re-linking
./APP: Symbol `_ZTVN6google8protobuf7MessageE' has different size in shared object, consider re-linking
If I compile the same source at this second machine it works fine, but if I run at the first machine, I get the error too.
I tried to copy all the libraries listed with ldd to an path at the other machine and I user the export LD_LIBRARY_PATH, and not working too.
ldd result at both machines are the same.
linux-vdso.so.1 => (0x00007ffd40fda000)
libsqlite3.so.0 => /usr/lib/x86_64-linux-gnu/libsqlite3.so.0 (0x00007f011b4b3000)
libzmq.so.5 => /usr/lib/x86_64-linux-gnu/libzmq.so.5 (0x00007f011b24d000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f011b030000)
libprotobuf.so.22 => /usr/local/lib/libprotobuf.so.22 (0x00007f011ab87000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f011a805000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f011a5ef000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f011a225000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f011a021000)
libsodium.so.18 => /usr/lib/x86_64-linux-gnu/libsodium.so.18 (0x00007f0119dc3000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f0119bbb000)
/lib64/ld-linux-x86-64.so.2 (0x00007f011b788000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f01198b2000)

Error while loading shared libraries: libpython2.7.so.1.0

Since a few days I get the following error when I try to open python that was installed with conda. The only thing that changed is that I changed the group of the files located in /software and gave the group read and write writes.
/software/local/share/bcbio/anaconda/bin/python: error while loading shared libraries: libpython2.7.so.1.0: cannot open shared object file: No such file or directory
I tried many different things. I first look at the output of ldd
ldd /software/local/share/bcbio/anaconda/bin/python
linux-vdso.so.1 => (0x00007ffd11bfc000)
libpython2.7.so.1.0 => /software/local/share/bcbio/anaconda/bin/../lib/libpython2.7.so.1.0 (0x00007f276fa9b000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00000036be600000)
libdl.so.2 => /lib64/libdl.so.2 (0x00000033bd800000)
libutil.so.1 => /lib64/libutil.so.1 (0x00000033bec00000)
libm.so.6 => /lib64/libm.so.6 (0x00000033be000000)
libc.so.6 => /lib64/libc.so.6 (0x00000033bd400000)
/lib64/ld-linux-x86-64.so.2 (0x00000033bd000000)
And looked at the permission of the librarie, which seemed to be correct:
ls -lah /software/local/share/bcbio/anaconda/bin/../lib/libpython2.7.so.1.0
-rwxrwsr-x+ 1 vsc lp_neuro 7.7M Jun 7 2018 /software/local/share/bcbio/anaconda/bin/../lib/libpython2.7.so.1.0
I also tried to export different environment variables:
export LD_LIBRARY_PATH=/software/local/share/bcbio/anaconda/bin/../lib/;
export PYTHONHOME=/software/local/share/bcbio/anaconda/bin/../lib/;
export PYTHONPATH=/software/local/share/bcbio/anaconda/bin/../lib/;
Since it is a conda installation of python, solutions needing root access (which I do not have) are of no uses. E.g. editing /etc/ld.so.conf is no option for me.
Is there a way to fix this issue?

mysql driver for qt database fedora

I understand it's the 100s time someone ask this but I'm still unable to have QMYSQL working.
So I installed qt-mysql but I'm still having the
QSqlDatabase: QMYSQL driver not loaded
QSqlDatabase: available drivers: QSQLITE
I copied /usr/lib64/qt4/plugins/sqldrivers/libqsqlmysql.so into /usr/lib64/qt5/plugins/sqldrivers/libqsqlmysql.so but no changes ...
I've also added QT += sql into the .pro file.
So what do I have to do ?
P.S. : I'm on Fedora 21 and I'm using QtCreator 3.3.2 based on Qt 5.4.1.
P.P.S : I also checked if the .so had dependencies problem but there's none :
$ ldd libqsqlmysql.so
linux-vdso.so.1 => (0x00007fff665d1000)
libmysqlclient.so.18 => /usr/lib64/mysql/libmysqlclient.so.18 (0x00007fcb07294000)
libQtSql.so.4 => /lib64/libQtSql.so.4 (0x00007fcb07052000)
libQtCore.so.4 => /lib64/libQtCore.so.4 (0x00007fcb06b63000)
libpthread.so.0 => /lib64/libpthread.so.0 (0x00007fcb06947000)
libstdc++.so.6 => /lib64/libstdc++.so.6 (0x00007fcb06638000)
libm.so.6 => /lib64/libm.so.6 (0x00007fcb0632f000)
libgcc_s.so.1 => /lib64/libgcc_s.so.1 (0x00007fcb06118000)
libc.so.6 => /lib64/libc.so.6 (0x00007fcb05d5b000)
libdl.so.2 => /lib64/libdl.so.2 (0x00007fcb05b56000)
libz.so.1 => /lib64/libz.so.1 (0x00007fcb05940000)
libgthread-2.0.so.0 => /lib64/libgthread-2.0.so.0 (0x00007fcb0573e000)
libglib-2.0.so.0 => /lib64/libglib-2.0.so.0 (0x00007fcb05404000)
librt.so.1 => /lib64/librt.so.1 (0x00007fcb051fc000)
/lib64/ld-linux-x86-64.so.2 (0x00007fcb07aa6000)
You can't just copy the Qt4 MYSQL driver into Qt5. Install it from the same place you installed the rest of Qt5. (Package qt5-qtbase-mysql perhaps: https://apps.fedoraproject.org/packages/qt5-qtbase-mysql ).
You should build mysql driver manually. The only driver that comes with the default installation of Qt is Sqlite driver.
Follow the instructions in http://doc.qt.io/qt-5.4/sql-driver.html#qmysql
Install mySQL connector.
Follow instructions here
libmysql.dll needs to be located somewhere where it can be found by the application. To make this happen, you can list it in your global PATH in Control Panel/System/Advanced System Settings/Environment variables or put libmysql.dll in the same folder as the Qt dlls in yourQtDirectory/bin.

Deploy Qt Application binaries on Ubuntu with shared libs

I want to deploy a Qt application I've made to run on any "Vanilla" Ubuntu. It could be a .deb package, or simply the binary with the required libraries. Thing is, I'm not sure how to do either.
I've tried to follow this tutorial: https://lemirep.wordpress.com/2013/06/01/deploying-qt-applications-on-linux-and-windows-3/ and I actually managed to make the application run on another computer but... It's supposed to play some videos and I got a message like:
defaultServiceProvider::requestService(): no service found for - "org.qt-project.qt.mediaplayer"
I've probably missed some libs. But I really don't know which ones. When I run ldd on my binary file, everything seems to be ok.
The results of the ldd are as follows:
libQt5MultimediaWidgets.so.5 => /home/mauker/Qt/5.3/gcc_64/lib/libQt5MultimediaWidgets.so.5 (0x00007f02a0adf000)
libQt5Multimedia.so.5 => /home/mauker/Qt/5.3/gcc_64/lib/libQt5Multimedia.so.5 (0x00007f02a07fc000)
libQt5Widgets.so.5 => /home/mauker/Qt/5.3/gcc_64/lib/libQt5Widgets.so.5 (0x00007f029ffb9000)
libQt5Xml.so.5 => /home/mauker/Qt/5.3/gcc_64/lib/libQt5Xml.so.5 (0x00007f029fd7b000)
libQt5Network.so.5 => /home/mauker/Qt/5.3/gcc_64/lib/libQt5Network.so.5 (0x00007f029fa17000)
libQt5Gui.so.5 => /home/mauker/Qt/5.3/gcc_64/lib/libQt5Gui.so.5 (0x00007f029f2f3000)
libQt5Core.so.5 => /home/mauker/Qt/5.3/gcc_64/lib/libQt5Core.so.5 (0x00007f029ebbf000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f029e8a1000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f029e68a000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f029e2c4000)
libQt5OpenGL.so.5 => /home/mauker/Qt/5.3/gcc_64/lib/libQt5OpenGL.so.5 (0x00007f029e06a000)
libGL.so.1 => /usr/lib/x86_64-linux-gnu/mesa/libGL.so.1 (0x00007f029dd98000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f029da92000)
libpulse.so.0 => /usr/lib/x86_64-linux-gnu/libpulse.so.0 (0x00007f029d849000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f029d62a000)
libgobject-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgobject-2.0.so.0 (0x00007f029d3d9000)
libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f029d0d1000)
libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f029cd9b000)
libicui18n.so.52 => /home/mauker/Qt/5.3/gcc_64/lib/libicui18n.so.52 (0x00007f029c97b000)
libicuuc.so.52 => /home/mauker/Qt/5.3/gcc_64/lib/libicuuc.so.52 (0x00007f029c5f2000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f029c3ee000)
libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f029c1ec000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f029bfe3000)
/lib64/ld-linux-x86-64.so.2 (0x00007f02a0cff000)
libjson-c.so.2 => /lib/x86_64-linux-gnu/libjson-c.so.2 (0x00007f029bdd8000)
libpulsecommon-4.0.so => /usr/lib/x86_64-linux-gnu/pulseaudio/libpulsecommon-4.0.so (0x00007f029bb70000)
libdbus-1.so.3 => /lib/x86_64-linux-gnu/libdbus-1.so.3 (0x00007f029b92b000)
libffi.so.6 => /usr/lib/x86_64-linux-gnu/libffi.so.6 (0x00007f029b723000)
libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f029b4e4000)
libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f029b2c5000)
libicudata.so.52 => /home/mauker/Qt/5.3/gcc_64/lib/libicudata.so.52 (0x00007f0299a5a000)
libwrap.so.0 => /lib/x86_64-linux-gnu/libwrap.so.0 (0x00007f029984f000)
libsndfile.so.1 => /usr/lib/x86_64-linux-gnu/libsndfile.so.1 (0x00007f02995e7000)
libasyncns.so.0 => /usr/lib/x86_64-linux-gnu/libasyncns.so.0 (0x00007f02993e0000)
libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f02991dc000)
libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f0298fd6000)
libnsl.so.1 => /lib/x86_64-linux-gnu/libnsl.so.1 (0x00007f0298dbb000)
libFLAC.so.8 => /usr/lib/x86_64-linux-gnu/libFLAC.so.8 (0x00007f0298b8a000)
libvorbisenc.so.2 => /usr/lib/x86_64-linux-gnu/libvorbisenc.so.2 (0x00007f02986bb000)
libvorbis.so.0 => /usr/lib/x86_64-linux-gnu/libvorbis.so.0 (0x00007f029848d000)
libogg.so.0 => /usr/lib/x86_64-linux-gnu/libogg.so.0 (0x00007f0298284000)
libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f0298069000)
I've tried to copy every single one of those libs to a folder called "lib", and then I've made this script to run my app:
#!/bin/sh
export QTDIR=""
export QT_PLUGIN_PATH=""
export LD_LIBRARY_PATH=`pwd`/libs
export QT_QPA_PLATFORM_PLUGIN_PATH=`pwd`/libs/platforms
./App
I'm obviously missing something here, but I have no clue where to look. Can you guys help me out with this? Is there a simpler way to deploy my program on Ubuntu? Should I try to make the .deb package? If so, how do I do it for a Qt application?
EDIT: Ok, I've managed to solve the first error setting my QT_PLUGIN_PATH to pwd/lib - But now I've got this message:
No decoder available for type 'video/x-h264(...)'
Which could be solved by installing ffmpeg library separately. But I'd really like to bundle all the libs somehow, or like I said before, to make a .deb package that solves everything for the user.
To solve your codec problem the target pc will need to have the corresponding gstreamer library installed, then its dependencies (ffmpeg), then the ffmpeg dependencies, an so on....
You will be in a world of pain as you will end bundling A LOT of libraries since some deps requires other deps. I suggest you to take the deb packaging route so all the dependencies will be handled automatically.
Check the ubuntu packaging guide or the debian one. You should split your deb packaging question in another post so you will get better responses.

Strange Python compilation results with "--enable-shared" flag

I am using Debian (which comes with Python-2.7.3), trying to compile Python-2.7.6 from source for use with mod_wsgi alongside Apache.
Apparently you must use --enable-shared when compiling for mod_wsgi usage, according to numerous answers.
Following these steps:
./configure --enable-shared --prefix=/usr/local/bin/python-2.7.6
make
make install
And then checking the interactive shell #
/usr/local/bin/python-2.7.6/bin/python
I am greeted with "Python 2.7.3 (default, Jan 2 2013, 14:09:21)" etc
Why is it resulting in Python 2.7.3?
I tried ldd against the executable and this is the result:
linux-vdso.so.1 => (0x00007fff271ff000)
libpython2.7.so.1.0 => /usr/lib/libpython2.7.so.1.0 (0x00007f1545638000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f154541c000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f1545217000)
libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007f1545014000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f1544d92000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f1544a06000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f15447ef000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f15445d9000)
/lib64/ld-linux-x86-64.so.2 (0x00007f1545b40000)
How do I stop it from using the system library and instead use the locally compiled version?
I know that it is a lot easier for me to just revert to using the system installed Python version, and that the real-world difference is zero. But this behaviour seems strange.
When you do the make of Python, run it as:
LD_RUN_PATH=/usr/local/lib make
Setting the environment variable LD_RUN_PATH forces 'python' executable generated to look in /usr/local/lib before /usr/lib for Python shared library.
This is mentioned in the mod_wsgi documentation.
http://code.google.com/p/modwsgi/wiki/CheckingYourInstallation#Python_Shared_Library
Before doing this again, make sure you do a 'make distclean' and rerun configure to make sure you haven't got old build products around.