在静态编译Qt 5.5

时间:2015-10-12 22:10:27

标签: qt build compilation qt5

我试图创建Qt的静态构建。我配置如下:

./configure -release -opensource -confirm-license -static -no-sql-sqlite -qt-zlib -qt-libpng -qt-libjpeg -qt-freetype -qt-xcb -icu -openssl -nomake examples -skip xmlpatterns

但是,我收到以下错误:

g++ -Wl,--gc-sections -Wl,-O1 -fuse-ld=gold -Wl,--enable-new-dtags -Wl,-rpath-link,/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtdeclarative/lib -Wl,-rpath-link,/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtbase/lib -o ../../bin/qmltestrunner .obj/main.o .obj/qmltestrunner_plugin_import.o   -L/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtdeclarative/lib -lQt5QuickTest -L/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtbase/lib -lQt5Test -lQt5Widgets -L/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtbase/plugins/platforms -lqxcb -L/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtbase/src/plugins/platforms/xcb/xcb-static -L/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtbase/plugins/xcbglintegrations -lqxcb-egl-integration -L/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_egl/xcb-static -lqxcb-glx-integration -L/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtbase/src/plugins/platforms/xcb/gl_integrations/xcb_glx/xcb-static -lQt5XcbQpa -lXi -lxcb-static -L/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtimageformats/plugins/imageformats -lqdds -lqicns -lqjp2 -lqmng -lqtga -lqtiff -lqwbmp -lqwebp -L/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtbase/plugins/imageformats -lqico -L/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtbase/plugins/egldeviceintegrations -lqeglfs-x11-integration -lX11-xcb -lxcb -lQt5EglDeviceIntegration -lQt5PlatformSupport -lfontconfig -lfreetype -lXrender -lXext -lX11 -ludev -lEGL -L/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtdeclarative/plugins/qmltooling -lqmldbg_qtquick2 -lQt5Quick -lQt5Gui -lqtharfbuzzng -lqmldbg_tcp -lQt5Qml -L/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtbase/plugins/bearer -lqconnmanbearer -lqgenericbearer -lqnmbearer -lQt5Network -lQt5DBus -lQt5Core -licui18n -licuuc -licudata -lqtpcre -lm -ldl -pthread -lgthread-2.0 -lrt -lglib-2.0 -lGL -lpthread
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QXcbIntegrationPlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QXcbEglIntegrationPlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QXcbGlxIntegrationPlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QDDSPlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QICNSPlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QJp2Plugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QMngPlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QTgaPlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QTiffPlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QWbmpPlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QWebpPlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QICOPlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QEglFSX11IntegrationPlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QConnmanEnginePlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QGenericEnginePlugin()'
.obj/qmltestrunner_plugin_import.o:qmltestrunner_plugin_import.cpp:function _GLOBAL__sub_I_qmltestrunner_plugin_import.cpp: error: undefined reference to 'qt_static_plugin_QNetworkManagerEnginePlugin()'
collect2: error: ld returned 1 exit status
make[3]: *** [../../bin/qmltestrunner] Error 1
make[3]: Leaving directory `/home/coin/tmp/qt-everywhere-opensource-src-5.5.0/qtdeclarative/tools/qmltestrunner'

这似乎是插件和静态构建之间的问题。配置确实发出以下警告:

  

警告:使用静态链接将禁用动态使用   加载插件。确保导入所有需要的静态插件,   或者将所需的模块编译到库中。

     

Qt现已配置为构建。只需运行' make'。   一旦构建完所有内容,您必须运行“make install”#39;。   Qt将安装到/usr/local/Qt-5.5.0

中      

在重新配置之前,请确保从中删除任何剩余物   上一个版本。

然而,它似乎表明它应该有效。问题是什么?我可以禁用这些插件或尝试使用它们的工具,因为我认为我不需要它们吗?

2 个答案:

答案 0 :(得分:1)

正如AlexanderVX所提到的,一个不干净的工作目录和一个不干净的rootfs目录,来自之前构建和安装SDK的动态版本,是我的问题。

我发现在配置期间使用'-nomake tests'选项允许完成SDK构建,但是在针对SDK编译我的应用程序时,我遇到了相同的链接器错误。

我将我的问题追溯到在rootfs的库目录中安装了静态和动态链接库(例如libqlinuxfb.a和libqlinuxfb.so)。然后链接器选择动态版本而不是库的静态构建版本,因此不存在'qt_static_plugin *'符号。干净的构建目录和已安装的rootfs解决了这个问题。

答案 1 :(得分:0)

像AlexanderVX指出的那样,不洁的工作目录对我来说是个问题。

git submodule foreach --recursive "git clean -dfx"

也可以进行清洁,比

快很多
make/jom clean