Static linking fails for Qt libs.
-
Have you checked where on your system the static qt-libraries reside? Do they live in the same directory as the dynamic ones?
Perhaps you can give the actual link command, so that you can see what qmake is doing. That might be revealing. (how to do that with qmake, I really don't anymore, sorry.) -
Have you checked where on your system the static qt-libraries reside? Do they live in the same directory as the dynamic ones?
Perhaps you can give the actual link command, so that you can see what qmake is doing. That might be revealing. (how to do that with qmake, I really don't anymore, sorry.) -
This is from my *.pro file.
QT += core xml
TARGET = cmdtool
CONFIG += c++11
CONFIG += static static-runtimeNote that static-runtime is a Windows only setting. CONFIG += static will only mean that your libs will be built statically, it doesn't influence the Qt libs.
libQt5Core.so.5 => /home/user/Qt/5.15.16/gcc_64/lib/libQt5Core.so.5 (0x00007f4345600000)
This looks indeed like a dynamic build of Qt is used - and, from the path, a Qt as provided by the Qt online installer. If you want to link Qt libs statically, you need to rebuild it yourself, with '-static' argument: see e.g. https://doc.qt.io/qt-5/linux-deployment.html#static-linking.
libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f4345200000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f4347528000)Even with a statically build Qt , you will still have these dependencies to system libs.
-
I am actually compiling qt with static libs. After this I try again.
also I can swap to cmake (As it seems to be recommended).
I'll let you know about my success ... -
@ademmler Interested to see how you proceed. My experience is that changing to cmake is definitively a good plan. My experiences with static libs and qt vary, though. It always took some additional and unexpected work to get it working.
-
@ademmler Qt is a framework, it does not have any compile log. Compile log is simply the output of the compiler during the build.
@jsulm thx for your response.
As Qt documentation says "Building Qt for Static Linking To use static linking, Qt must be built with the -static configuration option."
Hence I am compiling the Framework statically.
Now I am asking if there is a "log file" saved by default?
Might be an option in Qt configure ? -
@jsulm thx for your response.
As Qt documentation says "Building Qt for Static Linking To use static linking, Qt must be built with the -static configuration option."
Hence I am compiling the Framework statically.
Now I am asking if there is a "log file" saved by default?
Might be an option in Qt configure ? -
@ademmler I don't understand what exactly you're asking. You see the build log (compiler/linker output) while you're building. If you want to have it in a file then simply forward the output to a file.
-
@jsulm My host crashed while compile.
My simple question: Is there a log saved by default?This might be the case - Qt is a beast and who knows everything what's going on in the background.
@ademmler said in Static linking fails for Qt libs.:
My host crashed while compile
How exactly do you build on this host?
-
@jsulm My host crashed while compile.
My simple question: Is there a log saved by default?This might be the case - Qt is a beast and who knows everything what's going on in the background.
-
@ademmler said in Static linking fails for Qt libs.:
My host crashed while compile
How exactly do you build on this host?
To be precise it was after compile!
I was reading the output from make - as my virtual machine collapsed.
Because it took 12h to compile I am asking if there is somewhere a log file by default.However, now I got problem on top:
When I try to launch qtcreator it fails.Possible reason:
- Qt5static is the default - which was compiled without plattform plugins
- Conflicts between different qt Versions
5.15.16 dynamic (from installer)
5.15.16 static (compiled by me)
When I use qtchooser it has no effect
When I set QT_SELECT no effect../qmake -query QT_SYSROOT: QT_INSTALL_PREFIX:/home/user/Qt/5.15.16/gcc_64 QT_INSTALL_ARCHDATA:/home/user/Qt/5.15.16/gcc_64 QT_INSTALL_DATA:/home/user/Qt/5.15.16/gcc_64 QT_INSTALL_DOCS:/home/user/Qt/Docs/Qt-5.15.16 QT_INSTALL_HEADERS:/home/user/Qt/5.15.16/gcc_64/include QT_INSTALL_LIBS:/home/user/Qt/5.15.16/gcc_64/lib QT_INSTALL_LIBEXECS:/home/user/Qt/5.15.16/gcc_64/libexec QT_INSTALL_BINS:/home/user/Qt/5.15.16/gcc_64/bin QT_INSTALL_TESTS:/home/user/Qt/5.15.16/gcc_64/tests QT_INSTALL_PLUGINS:/home/user/Qt/5.15.16/gcc_64/plugins QT_INSTALL_IMPORTS:/home/user/Qt/5.15.16/gcc_64/imports QT_INSTALL_QML:/home/user/Qt/5.15.16/gcc_64/qml QT_INSTALL_TRANSLATIONS:/home/user/Qt/5.15.16/gcc_64/translations QT_INSTALL_CONFIGURATION:/home/user/Qt/5.15.16/gcc_64 QT_INSTALL_EXAMPLES:/home/user/Qt/Examples/Qt-5.15.16 QT_INSTALL_DEMOS:/home/user/Qt/Examples/Qt-5.15.16 QT_HOST_PREFIX:/home/user/Qt/5.15.16/gcc_64 QT_HOST_DATA:/home/user/Qt/5.15.16/gcc_64 QT_HOST_BINS:/home/user/Qt/5.15.16/gcc_64/bin QT_HOST_LIBS:/home/user/Qt/5.15.16/gcc_64/lib QMAKE_SPEC:linux-g++ QMAKE_XSPEC:linux-g++ QMAKE_VERSION:3.1 QT_VERSION:5.15.16 -
To be precise it was after compile!
I was reading the output from make - as my virtual machine collapsed.
Because it took 12h to compile I am asking if there is somewhere a log file by default.However, now I got problem on top:
When I try to launch qtcreator it fails.Possible reason:
- Qt5static is the default - which was compiled without plattform plugins
- Conflicts between different qt Versions
5.15.16 dynamic (from installer)
5.15.16 static (compiled by me)
When I use qtchooser it has no effect
When I set QT_SELECT no effect../qmake -query QT_SYSROOT: QT_INSTALL_PREFIX:/home/user/Qt/5.15.16/gcc_64 QT_INSTALL_ARCHDATA:/home/user/Qt/5.15.16/gcc_64 QT_INSTALL_DATA:/home/user/Qt/5.15.16/gcc_64 QT_INSTALL_DOCS:/home/user/Qt/Docs/Qt-5.15.16 QT_INSTALL_HEADERS:/home/user/Qt/5.15.16/gcc_64/include QT_INSTALL_LIBS:/home/user/Qt/5.15.16/gcc_64/lib QT_INSTALL_LIBEXECS:/home/user/Qt/5.15.16/gcc_64/libexec QT_INSTALL_BINS:/home/user/Qt/5.15.16/gcc_64/bin QT_INSTALL_TESTS:/home/user/Qt/5.15.16/gcc_64/tests QT_INSTALL_PLUGINS:/home/user/Qt/5.15.16/gcc_64/plugins QT_INSTALL_IMPORTS:/home/user/Qt/5.15.16/gcc_64/imports QT_INSTALL_QML:/home/user/Qt/5.15.16/gcc_64/qml QT_INSTALL_TRANSLATIONS:/home/user/Qt/5.15.16/gcc_64/translations QT_INSTALL_CONFIGURATION:/home/user/Qt/5.15.16/gcc_64 QT_INSTALL_EXAMPLES:/home/user/Qt/Examples/Qt-5.15.16 QT_INSTALL_DEMOS:/home/user/Qt/Examples/Qt-5.15.16 QT_HOST_PREFIX:/home/user/Qt/5.15.16/gcc_64 QT_HOST_DATA:/home/user/Qt/5.15.16/gcc_64 QT_HOST_BINS:/home/user/Qt/5.15.16/gcc_64/bin QT_HOST_LIBS:/home/user/Qt/5.15.16/gcc_64/lib QMAKE_SPEC:linux-g++ QMAKE_XSPEC:linux-g++ QMAKE_VERSION:3.1 QT_VERSION:5.15.16@ademmler I as I wrote before you can forward compiler output to a file. But I don't know why you actually need it? Simply start the build again, it will continue where it was interrupted.
"When I try to launch qtcreator it fails" - start it ffom a terminal and see whether there are any errors.
-
@ademmler I as I wrote before you can forward compiler output to a file. But I don't know why you actually need it? Simply start the build again, it will continue where it was interrupted.
"When I try to launch qtcreator it fails" - start it ffom a terminal and see whether there are any errors.
-
@ademmler said in Static linking fails for Qt libs.:
I wanted first to resolve missing stuff before I redo it
Reado what? I did not suggest to redo anything, I seggested to simply continue the build after crash. And what do you mean by "missing stuff"?
-
I still have no idea what precisely you are doing. Apparently, ,you are working on a virtual machine.
But you give no specifics about what you are really doing, other than in general terms.
But do you work from a terminal? (if not, I strongly suggest doing so). In my personal experience this is the best way to have control over the whole procedure.When you compile/install from a terminal, the procedure is in principle straight forward; Forget about QtCreator. first make sure the Qt libs are installed properly. Once that is ok, you can proceed with QtCreator (although personally I am no fan).
In the source tree, you have to run first the .configure script. It is all in the README.
It will tell you which features will be enabled, disabled, or if there are any essential packages missing.
You might have to run the configuration several times in order to satisfy all requirements.Next, once you have ensured that all essential packages are available on you virtual machine, you can go to the next phase:
compilation. Is your cmake-toolchain ok?Assuming that the compilation succeeds, the next stage is to install. Qt will be installed in the directory you specify when you run the configure script, e.g. ./configure -prefix /usr/local/qt-6.6.1
or ./configure -static -prefix /usr/local/qt-6.6.1-static
This directory is important. I always make sure that the static version of Qt is install in a separate directory, e.g. /usr/local/qt-6.6.1-static. Moreover, once done, I ensure the environment variable QTDIR is set to this very directory. This way, you prevent version conflicts.You see, there is so much additional info needed to address your issue systematically.
Good luck
Bertwim -
I still have no idea what precisely you are doing. Apparently, ,you are working on a virtual machine.
But you give no specifics about what you are really doing, other than in general terms.
But do you work from a terminal? (if not, I strongly suggest doing so). In my personal experience this is the best way to have control over the whole procedure.When you compile/install from a terminal, the procedure is in principle straight forward; Forget about QtCreator. first make sure the Qt libs are installed properly. Once that is ok, you can proceed with QtCreator (although personally I am no fan).
In the source tree, you have to run first the .configure script. It is all in the README.
It will tell you which features will be enabled, disabled, or if there are any essential packages missing.
You might have to run the configuration several times in order to satisfy all requirements.Next, once you have ensured that all essential packages are available on you virtual machine, you can go to the next phase:
compilation. Is your cmake-toolchain ok?Assuming that the compilation succeeds, the next stage is to install. Qt will be installed in the directory you specify when you run the configure script, e.g. ./configure -prefix /usr/local/qt-6.6.1
or ./configure -static -prefix /usr/local/qt-6.6.1-static
This directory is important. I always make sure that the static version of Qt is install in a separate directory, e.g. /usr/local/qt-6.6.1-static. Moreover, once done, I ensure the environment variable QTDIR is set to this very directory. This way, you prevent version conflicts.You see, there is so much additional info needed to address your issue systematically.
Good luck
Bertwim@BwvB Dear Bertwim,
thx for your response. My mistake - i have mixed to topics here.
- Ofcourse I compile from terminal.
- After compile and "make install" I ended up with 2 Qt Version:
- commercial license dynamic
- self compiled static
now I want to use Qtcreator for opening my project and work on this.
But after the compile and install everything is screwed up and qtcreator won't start any longer - while maintenance tool still does ...My question: I need to select the right qt installation to be used with qtcreator ... how do I do this if the QT_SELECT has no effect?
-
@BwvB Dear Bertwim,
thx for your response. My mistake - i have mixed to topics here.
- Ofcourse I compile from terminal.
- After compile and "make install" I ended up with 2 Qt Version:
- commercial license dynamic
- self compiled static
now I want to use Qtcreator for opening my project and work on this.
But after the compile and install everything is screwed up and qtcreator won't start any longer - while maintenance tool still does ...My question: I need to select the right qt installation to be used with qtcreator ... how do I do this if the QT_SELECT has no effect?
@ademmler Ah, I see what you are after. I think if you know the qt-installation that is needed for QtCreator (the one that is given to you originally) you can set those in a separate script (e.g. a bash script). So ensure QTDIR and perhaps LD_LIBRARY_CONFIG in this script are referring to the original QtConfig; then start QtCreator from this script. You can start this selfmade QtCreator script from a desktop icon, if you want.
In other words, ensure that in you script the environment is set ok for your copy of QtCreator. Then run this script.Success,
Bertwim -
I'm a little late to the party 😉. I have a comment about the original problem that there are some libraries which are dynamically linked. This could be solved for the Qt libs through recompilation (like you are trying), but it doesn't solve it for the other libraries. In any case it is a good idea to create an AppImage that has all the libraries included. In this case you can even include the Qt dynamic libraries into the AppImage. We are using a combination of linuxdeploy and linuxdeployqt to create the AppImage. In the end you have a single file that just looks like an executable to the end user (it is actually an executable which will mount the AppImage and run a specific command after that).