Unable to link Qt application statically
-
Hi
I am trying to build a Qt application with static library linking. I just followed this thread to configure and install Qt 5.5 to my target file system. My configuration options are given below:
./configure -static -confirm-license -opensource -opengl es2 -device linux-imx6-g++ -device-option CROSS_COMPILE=/home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf- -sysroot /home/acs//qt-rfs -release -nomake examples -nomake tests -skip webkit -skip multimedia -D QT_QML_NO_DEBUGGER --prefix=/my-qt
It successfully installed Qt to the target file system. But when i make a sample Qt application i am getting the following error:
/home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqeglfs /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqdds /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqicns /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqico /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqjp2 /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqmng /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqtga /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqtiff /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqwbmp /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqwebp /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqeglfs-viv-integration /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqmldbg_qtquick2 /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqmldbg_tcp /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqconnmanbearer /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqgenericbearer /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/5.2.1/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lqnmbearer
The corresponding part of Makefile is given below:
LINK = /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ LFLAGS = -mfloat-abi=hard --sysroot=/home/acs/qt-rfs -Wl,-O1 LIBS = $(SUBLIBS) -L/home/acs/qt-rfs/my-qt/lib -lQt5Quick -lQt5Gui -ljpeg -lpng -lqtharfbuzzng -lQt5Qml -lQt5Network -lproxy -lQt5Core -lz -lqtpcre -lm -ldl -pthread -lgthread-2.0 -lglib-2.0 -lrt -L/my-qt/plugins/platforms -lqeglfs -L/my-qt/plugins/imageformats -lqdds -lqicns -lqico -lqjp2 -lqmng -lqtga -lqtiff -lqwbmp -lqwebp -L/my-qt/plugins/egldeviceintegrations -lqeglfs-viv-integration -L/my-qt/plugins/qmltooling -lqmldbg_qtquick2 -lqmldbg_tcp -L/my-qt/plugins/bearer -lqconnmanbearer -lqgenericbearer -lqnmbearer -lGLESv2 -lEGL -lGAL -lpthread AR = /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-ar cqs RANLIB = SED = sed STRIP = /home/acs/gcc-linaro-5.2-2015.11-1-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-strip
I believe there is some issue with linking of plugin libraries statically. I tried giving absolute path to each plugin directories like,
-L/home/acs/qt-rfs/my-q/plugins/platforms -lqeglfs
Still I,m getting lots of Undefined Reference errors like bellow
home/acs/qt5.6/my-qt/plugins/qmltooling/libqmldbg_debugger.a(qdebugmessageservice.o): In function `QDebugMessageService::QDebugMessageService(QObject*)': qdebugmessageservice.cpp:(.text+0x16): undefined reference to `QQmlDebugService::QQmlDebugService(QString const&, float, QObject*)' qdebugmessageservice.cpp:(.text+0x3a): undefined reference to `QQmlDebugService::state() const' /home/acs/Downloads/L3.14.52_1.1.0-ga_images_MX6QDLSOLO/qt5.6/my-qt/plugins/qmltooling/libqmldbg_debugger.a(qdebugmessageservice.o): In function `QDebugMessageService::sendDebugMessage(QtMsgType, QMessageLogContext const&, QString const&)': qdebugmessageservice.cpp:(.text+0xa0): undefined reference to `QQmlDebugStream::QQmlDebugStream(QByteArray*, QFlags<QIODevice::OpenModeFlag>)' qdebugmessageservice.cpp:(.text+0x23e): undefined reference to `QQmlDebugService::name() const' qdebugmessageservice.cpp:(.text+0x248): undefined reference to `QQmlDebugService::messageToClient(QString const&, QByteArray const&)'
and lot more.....
Can any one help me with this issue?
-
Thank you for your response.
But my qmake is already making a plugin_import.cpp file which gets compiled on 'make'. If my understanding is correct , it it will import all the necessary plugins to project. the file is given below:
// This file is autogenerated by qmake. It imports static plugin classes for // static plugins specified using QTPLUGIN and QT_PLUGIN_CLASS.<plugin> variables. #include <QtPlugin> Q_IMPORT_PLUGIN(QEglFSIntegrationPlugin) Q_IMPORT_PLUGIN(QDDSPlugin) Q_IMPORT_PLUGIN(QICNSPlugin) Q_IMPORT_PLUGIN(QICOPlugin) Q_IMPORT_PLUGIN(QTgaPlugin) Q_IMPORT_PLUGIN(QTiffPlugin) Q_IMPORT_PLUGIN(QWbmpPlugin) Q_IMPORT_PLUGIN(QWebpPlugin) Q_IMPORT_PLUGIN(QEglFSVivIntegrationPlugin) Q_IMPORT_PLUGIN(QQmlDebuggerServiceFactory) Q_IMPORT_PLUGIN(QQmlInspectorServiceFactory) Q_IMPORT_PLUGIN(QLocalClientConnectionFactory) Q_IMPORT_PLUGIN(QQmlNativeDebugConnectorFactory) Q_IMPORT_PLUGIN(QQmlProfilerServiceFactory) Q_IMPORT_PLUGIN(QQmlDebugServerFactory) Q_IMPORT_PLUGIN(QTcpServerConnectionFactory) Q_IMPORT_PLUGIN(QConnmanEnginePlugin) Q_IMPORT_PLUGIN(QGenericEnginePlugin) Q_IMPORT_PLUGIN(QNetworkManagerEnginePlugin)
I have also tried with CONFIG -= import_plugins option and tried to include all the plugin libraries with QTPLUGIN += option but gets the same result. Also qmake says Project WARNING: Redundant entries in QTPLUGIN:
I am new to Qt and static library linking , please guide.
Thanks again -
@zappy
I don't build Qt statically (or anything for that matter), so I'm by no means an expert, but I don't think you're supposed to give the classes' names toQ_IMPORT_PLUGIN
but rather the plugin name (i.e. the library name), at least that's what is shown in the docs. AlsoQTPLUGIN += pluginname
seems to be non-optional. Try following the example exactly and with a simple tryout case (for example for theqjpeg
plugin) and see how it goes.PS.
I'm not completely convinced your problem is with the plugins though. Perhaps you should try disabling the build of the QML module if you don't need it. -
Thank you...
I have one finding.The Makefile generated by qmake includes a line given below
-L/my-qt/plugins/platforms -lqeglfs
and i confirm the presence of libeglfs.a in the above said location. But the libeglfs.pri file includes a line
QMAKE_PRL_LIBS = -L$$[QT_INSTALL_LIBS] -lQt5EglDeviceIntegration -lQt5PlatformSupport -lfontconfig -lfreetype -lQt5DBus -ldbus-1 -ludev -lQt5Gui -ljpeg -lpng -lqtharfbuzzng -lQt5Core -lz -lqtpcre -lm -ldl -pthread -lgthread-2.0 -lglib-2.0 -lrt -lGLESv2 -lEGL -lpthread
$$[QT_INSTALL_LIBS] is '/my-qt/lib'
and many of the above listed libraries are missing from the desired location (ie; libpng.a, libudev.a, libjpeg.a etc...).
The case is same for all other libraries as well
Is there any mistake in the static qt build procedure which i have done....
Should I compile those libraries manually and place them in the desired location. -
@zappy
Hello.Have you looked at the bug report in the other thread you were following? Apparently there were some bug in the static building for Qt 5.5 and it's fixed in Qt 5.6.1 (https://bugreports.qt.io/browse/QTBUG-51071). So aside from upgrading, am at a loss ...