Qt - How to deploy application dynamically on Linux? - c++

I have an application that I built using Qt Creator on Linux and want to deploy it now. However, I don't want to statically build it as I don't want it to be open-sourced. I tried the ldd ./YourExecutable command, however that only lists (and not add) the additional dependencies the application needs in order for it to run. My question is, how do I gather the necessary dependencies without having to individually look for these files? Is there a tool, such as windeployqt.exe on Windows, that I can use on Linux for the same purpose? Or is there a better approach than the one I'm thinking of?

Get Cygwin setup.exe: http://www.cygwin.com/
1.1. Run setup.exe and continue to package selection list.
1.2. Under Devel catagory select tools you need for compiling your source. For
example 'GNU make'.
1.3. Finish installing.
Get linux crosscompilers for cygwin:
"cygwin-gcc-linux.tar.bz2" (68.2 Mb).
md5sum: 340e91a346f5bb17e660db10e43005b8
These compilers are made with crosstool 0.28-rc37. This package contains:
gcc-3.3.4 and gcc-2.95.3 for i386 (glibc 2.1.3) and gcc-3.3.3 for amd64
(glibc 2.3.2).
Note! There is now newer version of GCC avaible with glibc 2.3.2:
"cygwin-gcc-3.3.6-glibc-2.3.2-linux.tar.bz2 (i386, x86_64)".
2.1. Copy 'cygwin-gcc-linux.tar.bz2' to 'c:\cygwin' or install directory which
you selected in setup.exe.
2.2. Open Cygwin shell and change directory to root with 'cd /'.
2.3. Uncompress to Cygwin root with command:
'tar -jxvf cygwin-gcc-linux.tar.bz2'.
Cross-compilers are installed under '/opt/crosstool'. You can use theim
directly or with commands: gcc-linux, g++-linux, gcc-linux-2.95,
g++-linux-2.95, gcc-linux-x86_64 and g++-linux-x86_64.
From: Cross-compiling on Windows for Linux
More info here.

It sounds like you want to use the shared library deployment option:
http://doc.qt.io/qt-5/linux-deployment.html#creating-the-application-package
Then if you wanted to go further than that, you could look into making a .rpm or a .deb .
There are lots of examples of qt projects that are now available on GitHub and have packages made. Usually for prebuilt binaries you need to make one for x86 and a separate one for x64.
Hope that helps.

Related

Stepping into Qt sources in Qt Creator (in Ubuntu Linux)

I'm using Qt Creator in Ubuntu. It's installed from the repositories but as it is now, there is no way to step into the Qt sources when debugging.
How can I enable that?
Since Qt Creator uses gdb, you need to configure gdb. First thing to do is to install Qt debugging symbols:
apt-get install libqt4-dbg
Or, for Qt5:
apt-get install qtbase5-dbg # For the qtbase package
This will install the debugging symbols for Qt libraries. Older releases of Ubuntu had a silly bug that required additional trick to correct those symbol files, but in the current release it works fine.
This will make gdb step inside Qt methods, but it's no fun without sources. So we need sources which can be installed like this, assuming that the source repository is enabled in the APT:
apt-get source qt4-x11
ln -s qt4-x11-4.7.0 qt # a convenience symlink
Or, for Qt5:
apt-get source qtbase-opensource-src
# Make a link as above, if you wish
This will download the sources, unpack them into the current directory and patch them accordingly, no root privileges needed unless the current dir isn't writeable by the current user.
And the last thing is to inform gdb of the sources location, which is done by putting this in the ~/.gdbinit file:
dir ~/vita/qt/src/corelib
dir ~/vita/qt/src/gui
dir ~/vita/qt/src/network
dir ~/vita/qt/src/sql
Add modules and correct paths as needed. The convenience symlink is very useful here, so we don't have to edit this file each time we upgrade to a new Qt version. We only need to download the new sources, patch them and change the symlink.
Note that even we have installed the debugging symbols, we still use the release build of Qt libraries. This means that the code is highly optimized and will sometimes behave very strange when stepping inside Qt binaries. If it is a problem, then it is necessary to build Qt in debug mode, install it separately (say, in /usr/local/qt4-debug) and tell Qt Creator to use that particular installation.
The only way i made it work on Ubuntu is building Qt from sources with configure -debug.
Everything started to work like a charm afterwards.
Qt binary packages for Linux don't contain debug symbols and therefore the debugger doesn't know files or line numbers where to jump to. You need to build Qt yourself with -debug configure option if you want to be able to debug Qt code.
Instructions from Sergey Tachenov instructions would only work if you build your application against the Qt version that you can find from Ubuntu repositories.

G++/GCC: how to make your app tell OS to download libs it needs into system?

So for example I am creating some app that uses boost or openCV and on my developer machine all that is installed so app compiles without any problem. But I wonder how to make app tell OS to download libs I use on first run? Is it possible? (sorry - I am linux noob)
This is what package managers are for. What you do is you compile your project, and then you build a package (e.g. .deb or .rpm), using the appropriate tools. While doing so, you can specify where the various files in your package should go, but also which other packages your package relies on. These are known as "dependencies", and package managers like apt and rpm are pretty good at resolving them.
Here's the official debian guide to making packages to give you an idea:
http://www.debian.org/doc/maint-guide/
Alternatively, you can just distribute your program as-is and list the dependencies in the install instructions; users will then have to manually install them through their package manager before running your program.

Needed environment for building gstreamer plugins in Windows

I've been strugling for two weeks to create an environment for building a gstreamer plugin on windows (needed for a songbird addon).
I've installed MSYS, MinGW and Cygwin, then installed GStreamer OSSBuild, and I also downloaded the sources for Songbird, which come with their own precompiled version of gstreamer.
I was unable to run gst-inspect (or any other gstreamer applications) from the songbird sources and I figured I will settle for OSSBuild (as I was able to run gst-inspect from the compiled OSSBuild).
When following the instructions for building a GST plugin (found here) through, cygwin will not recognize the OSSBuild and the build fails when running autogen, with the following error:
checking for GST... no
configure: error:
You need to install or upgrade the GStreamer development
packages on your system. On debian-based systems these are
libgstreamer0.10-dev and libgstreamer-plugins-base0.10-dev.
on RPM-based systems gstreamer0.10-devel, libgstreamer0.10-devel
or similar. The minimum version required is 0.10.16.
configure failed
I could also not use MSYS or MinGW as they are unable to run autogen at all.
I understand that cygwin should have it's own gstreamer development packages but I couldn't find how to install them.
My question: How do I install the gstreamer packages in cygwin or how do I build using cygwin with the OSSBuild dependencies?
In short, how do I get an environment where I can build a gstreamer plugin under windows?
you can install precompiled gstreamer packages for cygwin at cygwinports. there you will find installation instructions and a list of available packages. you should not need to build them from source.
Configure's most likely going to look for libtool (.la) or pkg-config (.pc) files. Since OSSBuild is built using MSVC, you're not likely to get those files so configure can pick them up. However, you can manually create them and set them in a location to be picked up by the script. I do know that OSSBuild does have as its goal to eventually provide Visual Studio-compatible C/C++ project templates for GStreamer plugins as well as libtool and pkg-config files, but they're not available just yet.
If you checkout the OSSBuild source and can follow MSVC property files, you can see how the plugins are setup and configured.

Compiling a shared library with Qt on Ubuntu 9.10

I am new to both Qt and Linux C++ development (although I have many years C and C++ development experience on Windows).
I have some legacy C projects (source files and headers - [not using Qt]) that I want to compile into shared libs on Linux.
I am proposing to store my projects under the following structure:
/home/username/Projects/project_name
/home/username/Projects/project_name/src
/home/username/Projects/project_name/build
Can anyone tell me how to do the following (using Qt to simplify the build process)
Create different build configurations (debug, release etc)
Build a configuration to create the appropriate shared library
As an aside, I have only recently installed Ubuntu 9.10 and the only C/C++ development tool I have installed (using SPM) in Qt - so I dont know if I need to install some other GNU C++ tools.
BTW I have already checked and have gcc (v4.4.1) available on my machine. I do not appear to have g++ though - I do not know whether this is significant or not.
An Ubuntu system doesn't come with build tool chain by default. Instead it has a meta package that you will need to install:
sudo apt-get install build-essential
This will install, among other the g++ compiler, although I am not sure about the Qt headers an such. For them you will need the qt4-dev package (I assume you wish to work with qt4 rather then qt3).
As for the bould structure, you will want to consult the qmake manual, or you might want to consider using CMake (apt-get install cmake) instead. CMake allow for out of build sources, as you require, and personally, I can't recommend it enough.

Enabling OpenGL in wxWidgets

I installed the wxWidgets source code, compiled it and am linking the libraries thus obtained with my application code. Now I need to use OpenGL in my wxWidgets application. How do I enable this?
For building on Windows with project files:
Assume $(WXWIDGETSROOT) is the root directory of your wxWidgets installation.
Open the file $(WXWIDGETSROOT)\include\wx\msw\setup.h
Search for the #define for wxUSE_GLCANVAS.
Change its value from 0 to 1.
Recompile the library.
For building on Linux and other ./configure based platforms:
Just use ./configure --with-opengl
(A mashup answer from two partial answers given by others)
If you're using configure to build wxWidgets you just need to add --with-opengl to your command line.
Just to add a little bit... If you're on linux you need to watch the logs when running configure. If it can't find opengl dev packages then it will turn opengl off with one line of warning which is easy to miss.
run it like this to make it more obvious what development libraries you're actually missing (it looks like the --with-opengl is on by default in 3.0.0 and possibly earlier versions of wxwidgets, but it can't hurt to include it I suspect).
./configure --with-opengl > configure.log
Once configure can find all the dev libs you think you're going to use you need to rebuild wxwidgets:
make
sudo make install
I had to install these on linux mint to make wxwidget's configure happy as far as opengl was concerned (and should also work for ubuntu) to get the dev libs I needed.
sudo apt-get install mesa-common-dev
sudo apt-get install freeglut3-dev
(Assume $(WX_WIDGETS_ROOT) is the root directory of your wxWidgets installation.)
Open the file $(WX_WIDGETS_ROOT)\include\wx\msw\setup.h
Search and find the option wxUSE_GLCANVAS. Change its value from 0 to 1.
Recompile the library.