Qt 5 linux 编译选项
来源:互联网 发布:算法模型dsp 编辑:程序博客网 时间:2024/04/30 16:07
./configure -prefix /home/smart/qt5 -debug-and-release -no-qml-debug -qt-zlib -no-journald -no-openssl -no-opengl -qt-xcb -skip qtquickcontrols -skip qtquickcontrols2 -skip qtsensors -skip qtdoc -no-compile-examples
在AIX上编译遇到问题:
(1)编译Core模块出错,未定义的符号:.flock,信息如下:
ld:0711-224 警告:重复符号:.sqrtf
ld:0711-345 使用 -bloadmap 或 -bnoquiet 选项获取更多信息。
ld:0711-317 错误:未定义的符号:.flock
collect2: error: ld returned 8 exit status
Makefile:1234: recipe for target '../../lib/libQt5Core.so.5.6.2' failed
gmake[2]: *** [../../lib/libQt5Core.so.5.6.2] Error 1
gmake[2]: Leaving directory 'qt5/qt-everywhere-opensource-src-5.6.2/qtbase/src/corelib
【解决方法】
进入到qt5/qt-everywhere-opensource-src-5.6.2/qtbase/src/corelib 目录,修改Makefile,LIBS增加 -lbsd
- linux下编译qt5.6.0静态库
- configure生成makefile
- 安装选项
- Configure选项
- 第三方库:
- 附加选项:
- QNX/Blackberry 选项:
- Android 选项:
- 生成makefile
- 遇到链接检查失败的情况
- 生成makefile后进行编译
- 编译时的错误
- 多重定义’QT_MODBUS()’和’QT_MODBUS_LOW()’
- qt_static_plugin_AssimpParserPlugin未定义
- 在Qt Creator中使用编译出的QT库
- 具体过程如图
- configure生成makefile
编译QT是一件比较麻烦的事情。所以如果没有必要,就不要编译了。如果你只需要使用QT的一些基本功能,那么就只编译源码目录下的qtbase
目录下的东西即可。
下面所介绍的都只是在linux下适用的(windows下使用MinGW也可以,QT提供的MinGW安装包是32位的,需要64位的可以参考)。
在编译前,最好先安装完成相关的依赖包,主要是xcb/opengl
等。编译器使用gcc5及以上版本速度会比较快。i5-4460 CPU @ 3.20GHz
+8G
内存下编译时间大概是2.5个小时。
编译的时候对磁盘空间要求非常非常的大75G ./qt-src/qt-opensource-src-5.6.0
(这是还没有完全编译完时候的情况),如果无法接受,就别编译debug
版本和examples
了。
提供一个我已经编译好的了
linux下64位gcc编译
http://pan.baidu.com/s/1eRMnf26 提取密码 iz39
windows下64位mingw编译
http://pan.baidu.com/s/1qYh7yGG 提取密码 6bur
因为编译的时候,安装路径已经硬编码到了qmake中(使用strings qmake|grep qt_
来查看)。
所以如果改变了安装的目录,需要到安装目录下的bin
目录下创建文件qt.conf
,其内容如下:
[Paths]Prefix = 安装路径
首先下载源码包qt-everywhere-opensource-src-5.6.0.7z
然后解压
7z x -o/home/o/qt-src/qt-opensource-src-5.6.0 qt-everywhere-opensource-src-5.6.0.7zcd /home/o/qt-src/qt-opensource-src-5.6.0
我这里解压到/home/o/qt-src/qt-opensource-src-5.6.0
中,解压后进入这个目录。
configure生成makefile
先使用./configure --help
来看看都有哪些参数,这里就不贴命令输出结果了,直接把选项都翻译出来
安装选项
你可以用这些来改变安装的布局。请注意,所有目录除sysconfdir
外,其他的应位于-prefix/ hostprefix下
Configure选项
下表中第一列中的*
表示默认并可行的。+
表示默认,但需要进行评估(检测),评估通过才可接受。
没有和有debug输出(仅适用于MAC) -force-debug-info强制为release构建输出调试信息 -developer-buildQt开发者编译和链接选项(包括自动测试/输出)*-no-optimized-tools即使在调试版本中,也不构建优化的主机工具 -optimized-tools构建优化的主机工具,即使在调试版本 -opensource编译和链接Qt开源版本 -commercial编译和链接的Qt商业版 -confirm-license自动确认许可证(使用开源或是商业) -c++std <edition>编译QT使用的C++标准 (c++98, c++11, c++14, c++1z) 默认: 最高支持版本*-shared创建并使用Qt共享库. -static创建并使用QT静态库 -no-largefile禁用大文件支持+-largefile启用QT访问大于4 GB的文件功能 -no-accessibility不编译的可访问性支持
禁用访问不推荐,它将破坏QStyle并且可能影响QT构建
这个选项启用将创建一个源不兼容版本的QT,这是不支持+-accessibility编译访问支持. -no-sql-<driver>完全禁用SQL <driver> . -qt-sql-<driver>在 Qt SQL 模块启用SQL <driver>,默认是不启用的. -plugin-sql-
<driver>
启用SQL <driver\>作为一个插件在运行时链接 <driver>
的可能值为: [ db2 ibase mysql oci odbc psql sqlite sqlite2 tds ] -system-sqlite利用操作系统SQLite -no-qml-debug不构建在QML调试支持+-qml-debug构建QML调试支持 -platform target构建的目标操作系统和编译器(默认检测主机系统)
读readme文件获取支持的操作系统和编译器列表 -no-sse2编译不要使用SSE2指令 -no-sse3编译不要使用SSE3指令 -no-ssse3编译不要使用SSSE3指令 -no-sse4.1编译不要使用SSE4.1指令 -no-sse4.2编译不要使用SSE4.2指令 -no-avx编译不要使用AVX指令 -no-avx2编译不要使用AVX2指令 -no-mips_dsp编译不要使用MIPS DSP指令 -no-mips_dspr2编译不要使用MIPS DSP Rev2指令 -qtnamespace <name>把所有的Qt库代码放入
namespace <name> {...}
中 -qtlibinfix <infix>重命名所有libQt*.so
为libQt*<infix>.so
-testcocoonInstrument Qt with the TestCocoon code coverage tool. -gcovInstrument Qt with the GCov code coverage tool. -D <string>显示的添加一个宏定义到预处理器 -I <string>显示的添加一个包含路径 -L <string>显示添加一个库路径+-pkg-config使用pkg-config检测包括库路径。默认情况下,配置决定是否使用pkg-config或不具有启发式如检查环境变量。 -no-pkg-config禁用pkg-config支持 -force-pkg-config强制使用pkg-config (跳过pkg-config可用性启发式检测). -help, -h显示帮助信息.第三方库:
http://www.gzip.org/zlib -no-mtdev不要编译mtdev支持
mtdev包含了应用程序对多点触摸协议的支持+-mtdev启用mtdev的支持.+-no-journald不要把日志输出到journald.
Journald是为Linux服务器打造的新系统日志方式 -journald日志输出到journald+-no-syslog不要输出日志到syslog. -syslog输出日志到syslog. -no-gif不要编译GIF读取支持 -no-libpng不要编译PNG支持 -qt-libpng使用Qt自带的libpng+-system-libpng使用操作系统自带的libpng
http://www.libpng.org/pub/png -no-libjpeg不要编译JPEG支持. -qt-libjpeg使用QT自带的libjpeg.+-system-libjpeg使用系统自带的 libjpeg
http://www.ijg.org -no-freetype不要编译Freetype2的支持. -qt-freetype使用QT自带的libfreetype.+-system-freetype使用系统自带的libfreetype(假如存在) (启用,如果-fontconfig选项开启).
http://www.freetype.org -no-harfbuzz不要编译HarfBuzz-NG 支持.*-qt-harfbuzz使用QT自带的HarfBuzz-NG 去进行文本构形. 仍然可以通过设置
QT_HARFBUZZ
环境变量到”old”来禁用. -system-harfbuzz使用系统自带的HarfBuzz-NG区进行文本构形.仍然可以通过设置QT_HARFBUZZ
环境变量到”old”来禁用 http://www.harfbuzz.org -no-openssl不要编译OpenSSL的支持 -openssl启用运行时OpenSSL支持. -openssl-linked启用并链接OpenSSL支持 -no-libproxy不要编译libproxy的支持+-libproxy使用操作系统自带的libproxy. -qt-pcre使用QT自带的PCRE library.+-system-pcre使用操作系统自带的PCRE library -qt-xcb使用QT自带的xcb-libraries. (
libxcb.so
将仍然使用操作系统自带的).+-system-xcb使用操作吸引自带的xcb- libraries . -xkb-config-root设置默认的XKB config root. 这个选项仅与-qt-xkbcommon-x11一起使用. -qt-xkbcommon-x11在构建xcb中使用QT自带的xkbcommon library .+-system-xkbcommon-x11在构建xcb中使用操作系统自带的 xkbcommon library. -no-xkbcommon-evdev当编译libinput支持时,不使用X-less xkbcommon.*-xkbcommon-evdev当编译libinput支持时,使用X-less xkbcommon. -no-xinput2不要编译XInput2的支持.*-xinput2编译XInput2支持. -no-xcb-xlib不要编译Xcb-Xlib支持.*-xcb-xlib编译 Xcb-Xlib支持. -no-glib不要编译 Glib 支持.+-glib编译 Glib 支持. -no-pulseaudio不要编译PulseAudio 支持.+-pulseaudio编译 PulseAudio 支持. -no-alsa不要编译 ALSA 支持.+-alsa编译 ALSA 支持. -no-gtkstyle不要编译GTK theme 支持.+-gtkstyle编译 GTK theme 支持.附加选项:
在苹果的平台上,这意味着使用绝对安装名称(基于在libdir)动态库和框架。+-rpath链接 Qt 库和可执行文件使用库安装路径作为运行时库路径。相当于-R install_libpath -continue如果发生错误,尽量继续。 -verbose, -v打印每个步骤的配置过程的详细的信息。 -silent减少生成输出,这样可以更容易看到警告和错误。 -no-nis不要编译NIS 支持.*-nis编译 NIS 支持. -no-cups不要编译CUPS支持.*-cups编译CUPS支持. 要求 cups/cups.h 和libcups.so.2. -no-iconv不编译对 iconv(3) 的支持。*-iconv编译对 iconv(3) 的支持。 -no-evdev不编译对 evdev 的支持。*-evdev编译对 evdev 的支持。 -no-tslib不编译对 tslib 的支持
tslib是对触屏的支持*-tslib编译对 tslib 的支持. -no-icu不编译对 ICU libraries 的支持.
这是IBM发布的字符集编码转换库+-icu编译对 ICU libraries 的支持. -no-fontconfig不编译系统中的FontConfig支持+-fontconfig编译系统中的FontConfig支持 -no-strip不对二进制文件和库的使用strip去除不需要的符号.*-strip在安装时对二进制文件和库的使用strip去除不需要的符号*-no-pch不使用预编译的头支持. -pch使用预编译的头支持.*-no-ltcg不使用链接时代码生成 -ltcg使用链接时代码生成. -no-dbus不要编译Qt D-Bus 模块.+-dbus-linked编译Qt D-Bus模块并链接到libdbus-1. -dbus-runtime编译Qt D-Bus模块并动态加载libdbus-1. -reduce-relocations减少通过额外的链接器优化库的重加载
(仅qt/X11 和Qt/linux嵌入式 ;实验性的;需要 GNU ld > = 2.18) -no-use-gold-linker不要使用GNU gold linker进行链接.+-use-gold-linker使用GNU gold linker进行链接. -force-asserts强制启用Q_ASSERT,即使在release构建中. -sanitize
[address/thread/memory/undefined]
启用指定编译器的sanitizer. -device <name>跨平台编译<name>
设备 (试验性) -device-option <key=value>
添加device mkspec的device选项 (试验性)*-no-separate-debug-info不将调试信息存储在一个单独的文件 -separate-debug-info将调试信息到一个单独的文件 -no-xcb不要编译Xcb (X protocol C-language Binding) 支持.*-xcb编译 Xcb 支持. -no-eglfs不要编译EGLFS (EGL Full Screen/Single Surface) 支持.*-eglfs编译 EGLFS 支持. -no-kms不要编译KMS的后端.*-kms编译 KMS的后端. -no-gbm不要编译 GBM 的后端.*-gbm编译 GBM的后端. -no-directfb不要编译 DirectFB 支持.*-directfb编译 DirectFB 支持. -no-linuxfb不要编译Linux Framebuffer 支持.*-linuxfb编译 Linux Framebuffer 支持.*-no-mirclient不要编译 Mir client 支持. -mirclient编译 Mir client 支持. -qpa <name>设置默认的QPA 平台 (示例 xcb, cocoa, windows). -xplatform target指定目标平台(在跨平台编译时) -sysroot <dir>将<dir>
设置为目标编译器和 qmake 的 sysroot 并且也设置 pkg-confing路径. -no-gcc-sysroot当使用-sysroot时, 它禁用将–sysroot传递到编译器 -no-feature-<feature>
在<feature>
中的不编译. -feature-<feature>
编译<feature>
中的. 可用的功能介绍在src/corelib/global/qfeatures.txt -qconfig local使用src/corelib/global/qconfig-local.h ,而不是默认的(全部). -qreal [double/float]为qreal指定类型.默认值是double。请注意,更改此标志影响二进制兼容性。 -no-opengl禁用OpenGL支持. -opengl <api>启用 OpenGL 支持.
不带参数时,这将会尝试自动检测的 OpenGL ES 2.0 和更高版本,或常规的桌面版OpenGL.
使用 es2 的
<api>
将替代自动检测 -no-libinput禁用libinput支持.*-libinput启用libinput 支持. -no-gstreamer禁用GStreamer支持.+-gstreamer <version>
启用 GStreamer 支持。不带参数,这将会尝试自动检测 GStreamer 0.10 和 1.0。GStreamer 1.0 是默认使用的可用时。使用 0.10 或 1.0
<version>
来覆盖自动检测。*-no-system-proxies默认情况下,不使用系统网络代理 -system-proxies默认情况下,使用系统网络代理 -no-warnings-are-errorsMake 时把warnings当做正常 -warnings-are-errorsMake时把warnings 当做错误 (如果启用了-developer-build)QNX/Blackberry 选项:
Android 选项:
(默认 $ANDROID_SDK_ROOT) -android-ndk pathAndroid NDK 根目录.
(默认 $ANDROID_NDK_ROOT) -android-ndk-platform设置android 平台版本
(默认 android-9) -android-ndk-host设置android NDK 主机类型 (linux-x86, linux-x86_64, etc.)
(默认 $ANDROID_NDK_HOST) -android-arch设置android 体系结构 (armeabi, armeabi-v7a, x86, mips, arm64-v8a, x86_64, mips64)
(默认 armeabi-v7a) -android-toolchain-version设置android 工具链版本
(默认 4.9) -no-android-style-assets不编译 通过运行时设备自动提取style-assets的代码.
设置这将使Android风格的行为不当,但与lgpl2.1许可兼容*-android-style-assets编译 通过运行时设备自动提取style-assets的代码.
此选项将使Android平台的lgpl2.1许可不兼容。
生成makefile
下面是我编译的时候使用的选项。
-platform这一个选项是用于指定目标平台的,可以看qt源码目录/qtbase/mkspecs/
下的的目录,就是QT支持的平台。可以进这个目录修改qmake.conf
文件来指定编译器和编译选项。
如果同同时指定了-release
和-debug
使用的是后者。需要同时编译两个版本的时候应该使用-debug-and-release
.例如下面的输出。
因为很多模块我也不需要,就用过-skip <module>
来跳过。模块的名字就是qt-opensource-src-5.6.0
下目录的名字(不要-skip qtbase).
/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0 [o@o-pc] [12:09]>./configure -prefix /home/o/pragram/qt_5.6.0_gcc5.2.1 -debug-and-release -confirm-license -opensource -c++std c++11 -static -qt-sql-mysql -qt-sql-sqlite -no-qml-debug -platform linux-g++-64 -qt-zlib -no-journald -qt-libpng -qt-libjpeg -openssl -opengl -qt-xcb -skip qtquickcontrols -skip qtquickcontrols2 -skip qtsensors -skip qtdoc
下面是询问是否查看开源协议或者直接接受的。直接yes通过就好。也可以通过-confirm-license
选项来自动确认
Type '3' to view the GNU Lesser General Public License version 3.Type 'L' to view the Lesser GNU General Public License version 2.1.Type 'yes' to accept this license offer.Type 'no' to decline this license offer.Do you accept the terms of either license? yes... ...
遇到链接检查失败的情况
这里给出一个示例,就是xcb库检查失败。
Running configuration tests (phase 1)...Done running configuration tests.Creating qmake....Done.Running configuration tests (phase 2)...The test for linking against libxcb and support libraries failed! You might need to install dependency packages, or pass -qt-xcb. See src/plugins/platforms/xcb/README.
这个很好解决,安装下libxcb-***-dev
就是了。其他的库检查失败也是一样的。也可以通过-qt-xcb
选项,使用Qt自带的xcb
库。
生成makefile后进行编译
configure成功后会出现如下提示,后面说让你使用make进行编译,make install进行安装。
有一个警告Using static linking will disable the WebKit module.
意思是 使用静态链接将禁用WebKit模块。
最后面还有一个警告是WARNING: Using static linking will disable the use of dynamically loaded plugins. Make sure to import all needed static plugins, or compile needed modules into the library.
意思是警告:使用静态链接将禁用动态加载插件的使用。确保导入所有需要的静态插件,或者编译所需的模块到库中。
这不是一个好的做法。
Done running configuration tests. Configure summaryBuild type: linux-g++-64 (x86_64, CPU features: mmx sse sse2)Build options: Configuration .......... accessibility accessibility-atspi-bridge alsa audio-backend avx avx2 c++11 clock-gettime clock-monotonic compile_examples concurrent dbus dbus-linked egl eglfs egl_x11 enable_new_dtags evdev eventfd fontconfig full-config getaddrinfo getifaddrs gif glib gstreamer-0.10 harfbuzz iconv icu inotify ipv6ifname jpeg kms large-config largefile libudev linuxfb medium-config minimal-config mremap nis no-qml-debug opengl openssl png posix_fallocate precompile_header pulseaudio qpa qpa reduce_exports reduce_relocations release rpath small-config sse2 sse3 sse4_1 sse4_2 ssse3 static system-freetype threadsafe-cloexec use_gold_linker xcb xcb-plugin xcb-qt xcb-sm xcb-xlib xinput2 xkbcommon-evdev xkbcommon-qt xlib xrender zlib Build parts ............ libs tools examples Mode ................... release Using sanitizer(s)...... none Using C++ standard ..... c++11 Using gold linker....... yes Using new DTAGS ........ yes Using PCH .............. yes Using LTCG ............. no Target compiler supports: SSE2/SSE3/SSSE3 ...... yes/yes/yes SSE4.1/SSE4.2 ........ yes/yes AVX/AVX2 ............. yes/yesQt modules and options: Qt D-Bus ............... yes (linked to dbus-1) Qt Concurrent .......... yes Qt GUI ................. yes Qt Widgets ............. yes Large File ............. yes QML debugging .......... no Use system proxies ..... noSupport enabled for: Accessibility .......... yes ALSA ................... yes CUPS ................... no Evdev .................. yes FontConfig ............. yes FreeType ............... yes (system library) Glib ................... yes GStreamer .............. yes (0.10) GTK theme .............. no HarfBuzz ............... yes (bundled copy) Iconv .................. yes ICU .................... yes Image formats: GIF .................. yes (in QtGui, using bundled copy) JPEG ................. yes (in QtGui, using bundled copy) PNG .................. yes (in QtGui, using bundled copy) libinput................ no Logging backends: journald ............... no syslog ............... no mtdev .................. no Networking: getaddrinfo .......... yes getifaddrs ........... yes IPv6 ifname .......... yes libproxy.............. no OpenSSL .............. yes (loading libraries at run-time) NIS .................... yes OpenGL / OpenVG: EGL .................. yes OpenGL ............... desktop OpenVG ............... no PCRE ................... system pkg-config ............. yes PulseAudio ............. yes QPA backends: DirectFB ............. no EGLFS ................ yes EGLFS i.MX6 ........ no EGLFS i.MX6 Wayland. no EGLFS EGLDevice .... no EGLFS GBM .......... no EGLFS Mali ......... no EGLFS Raspberry Pi . no EGLFS X11 .......... yes LinuxFB .............. yes Mir client............ no XCB .................. yes (bundled copy) EGL on X ........... yes GLX ................ no MIT-SHM ............ yes Xcb-Xlib ........... yes Xcursor ............ yes (loaded at runtime) Xfixes ............. yes (loaded at runtime) Xi ................. no Xi2 ................ yes Xinerama ........... yes (loaded at runtime) Xrandr ............. yes (loaded at runtime) Xrender ............ yes XKB ................ yes XShape ............. yes XSync .............. yes XVideo ............. yes Session management ..... yes SQL drivers: DB2 .................. no InterBase ............ no MySQL ................ qt OCI .................. no ODBC ................. yes (plugin) PostgreSQL ........... yes (plugin) SQLite 2 ............. no SQLite ............... qt-qt TDS .................. no tslib .................. no udev ................... yes xkbcommon-x11........... yes (bundled copy, XKB config root: /usr/share/X11/xkb) xkbcommon-evdev......... yes zlib ................... yes (bundled copy)WARNING: Using static linking will disable the use of dynamicallyloaded plugins. Make sure to import all needed static plugins,or compile needed modules into the library.Info: creating super cache file /home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/.qmake.superQt is now configured for building. Just run 'make'.Once everything is built, you must run 'make install'.Qt will be installed into /home/o/pragram/qt_5.6.0_gcc5.2.1Prior to reconfiguration, make sure you remove any leftovers fromthe previous build.
编译时的错误
编译的过程中会出现各种各样的错误,导致不能编译通过,这是最编译QT的时候最常碰见的。这里列举出我碰见的的错误。
多重定义’QT_MODBUS()’和’QT_MODBUS_LOW()’
错误提示如下
g++ -m64 -fuse-ld=gold -Wl,--enable-new-dtags -o adueditor .obj/main.o .obj/mainwindow.o .obj/modbustcpclient.o .obj/adueditor_plugin_import.o .obj/moc_mainwindow.o .obj/moc_plaintextedit.o .obj/moc_modbustcpclient.o -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/lib -lQt5Widgets -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtserialbus/lib -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtserialport/lib -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/platforms -lqxcb -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/xcbglintegrations -lqxcb-egl-integration -lqxcb-glx-integration -lxcb-glx -lQt5XcbQpa -lXi -lxcb-render-util -lSM -lICE -lxcb-render -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-shape -lxcb-keysyms -lxcb-xinerama -lxcb-xkb -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtimageformats/plugins/imageformats -lqdds -lqicns -lqjp2 -ljasper -lqtga -lqtiff -ltiff -lqwbmp -lqwebp -lwebp -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/imageformats -lqico -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/egldeviceintegrations -lqeglfs-x11-integration -lX11-xcb -lxcb -lQt5EglDeviceIntegration -lQt5PlatformSupport -lfontconfig -lfreetype -lXrender -lXext -lX11 -lQt5Gui -lqtharfbuzzng -lEGL -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtserialbus/plugins/canbus -lqtpeakcanbus -lqtsocketcanbus -lqttinycanbus -lQt5SerialBus -lQt5SerialPort -ludev -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/bearer -lqconnmanbearer -lqgenericbearer -lqnmbearer -lQt5Network -lQt5DBus -ldbus-1 -lQt5Core -licui18n -licuuc -licudata -lpcre16 -lm -ldl -lgthread-2.0 -pthread -lglib-2.0 -lrt -lGL -lpthread /usr/bin/ld.gold: error: /home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtserialbus/lib/libQt5SerialBus.a(qmodbusdevice.o): multiple definition of 'QT_MODBUS()'/usr/bin/ld.gold: .obj/mainwindow.o: previous definition here/usr/bin/ld.gold: error: /home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtserialbus/lib/libQt5SerialBus.a(qmodbusdevice.o): multiple definition of 'QT_MODBUS_LOW()'/usr/bin/ld.gold: .obj/mainwindow.o: previous definition herecollect2: error: ld returned 1 exit statusMakefile:91: recipe for target 'adueditor' failedmake: *** [adueditor] Error 1
解决的办法很简单,把下面几行注释掉即可。
/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtserialbus/examples/serialbus/modbus/adueditor [o@o-pc] [13:07]> grep QT_MODBUS *mainwindow.cpp:Q_LOGGING_CATEGORY(QT_MODBUS, "qt.modbus")mainwindow.cpp:Q_LOGGING_CATEGORY(QT_MODBUS_LOW, "qt.modbus.lowlevel")modbustcpclient_p.h: qCDebug(QT_MODBUS_LOW) << "Sent TCP ADU:" << buffer.toHex();
这个错误的来源在于qt-everywhere-opensource-src-5.6.0/qtserialbus/lib/libQt5SerialBus.a(qmodbusdevice.o)
这个文件中对’QT_MODBUS()’和’QT_MODBUS_LOW()’有多重定义,所以解决问题还得回到这里。
打开qt-everywhere-opensource-src-5.6.0/qtserialbus/src/serialbus
目录下的amodbusdevice.cpp
文件,可以看到最后两行定义了’QT_MODBUS()’和’QT_MODBUS_LOW()’,并且是在QT_BEGIN_NAMESPACE
下。而这里在mainwindow.cpp
文件中也定义了一次,所以导致了重定义,这里注释掉即可。注释后重新编译即没有问题。
qt_static_plugin_AssimpParserPlugin未定义
这个问题在qt-everywhere-opensource-src-5.6.0/qt3d/examples/qt3d/
目录下的qml工程都存在这个问题。这个问题的原因就是没有AssimpParserPlugin
这个插件,我找到了这个插件,在qt-everywhere-opensource-src-5.6.0/qt3d/plugin
目录下。
问题来源如下
/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qt3d/examples/qt3d/playground-qml [o@o-pc] [14:56]> makeg++ -m64 -fuse-ld=gold -Wl,--enable-new-dtags -o playground-qml .obj/window.o .obj/main.o .obj/playground-qml_qml_plugin_import.o .obj/playground-qml_plugin_import.o .obj/qrc_playground-qml.o .obj/qrc_gltf.o .obj/moc_window.o -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qt3d/lib -lQt53DInput -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/lib -lQt53DQuick -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtdeclarative/lib -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qt3d/plugins/sceneparsers -lassimpsceneparser -lgltfsceneparser -lQt53DRender -lQt53DCore -lQt5OpenGLExtensions -lQt5Concurrent -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/platforms -lqxcb -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/xcbglintegrations -lqxcb-egl-integration -lqxcb-glx-integration -lxcb-glx -lQt5XcbQpa -lXi -lxcb-render-util -lSM -lICE -lxcb-render -lxcb-image -lxcb-icccm -lxcb-sync -lxcb-xfixes -lxcb-shm -lxcb-randr -lxcb-shape -lxcb-keysyms -lxcb-xinerama -lxcb-xkb -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtimageformats/plugins/imageformats -lqdds -lqicns -lqjp2 -ljasper -lqtga -lqtiff -ltiff -lqwbmp -lqwebp -lwebp -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/imageformats -lqico -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/egldeviceintegrations -lqeglfs-x11-integration -lX11-xcb -lxcb -lQt5EglDeviceIntegration -lQt5PlatformSupport -lfontconfig -lfreetype -lXrender -lXext -lX11 -ludev -lEGL -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtdeclarative/plugins/qmltooling -lqmldbg_debugger -lqmldbg_inspector -lQt5Quick -lqmldbg_local -lqmldbg_native -lQt5Gui -lqtharfbuzzng -lqmldbg_profiler -lqmldbg_server -lqmldbg_tcp -lQt5Qml -L/home/o/qt-src/qt-opensource-src-5.6.0/qt-everywhere-opensource-src-5.6.0/qtbase/plugins/bearer -lqconnmanbearer -lqgenericbearer -lqnmbearer -lQt5Network -lQt5DBus -ldbus-1 -lQt5Core -licui18n -licuuc -licudata -lpcre16 -lm -ldl -lgthread-2.0 -pthread -lglib-2.0 -lrt -lGL -lpthread playground-qml_plugin_import.cpp:4: error: undefined reference to 'qt_static_plugin_AssimpParserPlugin()'collect2: error: ld returned 1 exit statusMakefile:105: recipe for target 'playground-qml' failedmake: *** [playground-qml] Error 1
这个错误出现的原因在于playground-qml_plugin_import.cpp
文件中使用了Q_IMPORT_PLUGIN(AssimpParserPlugin)
来引入静态插件AssimpParserPlugin
的。如果是动态插件,是不需要这么引入的。静态插件将编译到目标程序中去。
没有这个插件,那么就先把它注释掉,再编译就可以了。
因为playground-qml_plugin_import.cpp
是Qt的qml工具生成的,所以需要在qmake
之后再去修改这个文件。
在Qt Creator中使用编译出的QT库
编译完成后,使用make install
进行安装。如果你没有指定安装的目录,可能需要root
权限。
可以先去安装目录中的目录结构
/home/o/pragram/qt_5.6.0_gcc5.2.1 [o@o-pc] [1:49]> lsbin doc examples include lib mkspecs phrasebooks plugins qml translations/home/o/pragram/qt_5.6.0_gcc5.2.1 [o@o-pc] [1:49]> ls bin assistant fixqt4headers.pl lrelease pixeltool qdbuscpp2xml qdoc qhelpgenerator qml qmllint qmltestrunner qtplugininfo syncqt.pl xmlpatternsvalidatorcanbusutil lconvert lupdate qcollectiongenerator qdbusviewer qgltf qlalr qmleasing qmlmin qtdiag qtwaylandscanner uicdesigner linguist moc qdbus qdbusxml2cpp qhelpconverter qmake qmlimportscanner qmlprofiler qtpaths rcc xmlpatterns/home/o/pragram/qt_5.6.0_gcc5.2.1 [o@o-pc] [1:49]> ls lib cmake libQt53DQuick.la libQt5Core.la libQt5Location.la libQt5OpenGL.la libQt5QuickParticles.prl libQt5Sql.la libQt5Widgets.lalibEnginio.a libQt53DQuick.prl libQt5Core.prl libQt5Location.prl libQt5OpenGL.prl libQt5Quick.prl libQt5Sql.prl libQt5Widgets.prllibEnginio.la libQt53DQuickRender.a libQt5DBus.a libQt5Multimedia.a libQt5PlatformSupport.a libQt5QuickTest.a libQt5Svg.a libQt5X11Extras.alibEnginio.prl libQt53DQuickRender.la libQt5DBus.la libQt5Multimedia.la libQt5PlatformSupport.la libQt5QuickTest.la libQt5Svg.la libQt5X11Extras.lalibpoly2tri.a libQt53DQuickRender.prl libQt5DBus.prl libQt5Multimedia.prl libQt5PlatformSupport.prl libQt5QuickTest.prl libQt5Svg.prl libQt5X11Extras.prllibpoly2tri.prl libQt53DRender.a libQt5Designer.a libQt5MultimediaQuick_p.a libQt5Positioning.a libQt5QuickWidgets.a libQt5Test.a libQt5XcbQpa.alibqgsttools_p.a libQt53DRender.la libQt5DesignerComponents.a libQt5MultimediaQuick_p.la libQt5Positioning.la libQt5QuickWidgets.la libQt5Test.la libQt5XcbQpa.lalibqgsttools_p.prl libQt53DRender.prl libQt5DesignerComponents.la libQt5MultimediaQuick_p.prl libQt5Positioning.prl libQt5QuickWidgets.prl libQt5Test.prl libQt5XcbQpa.prllibQt53DCore.a libQt5Bluetooth.a libQt5DesignerComponents.prl libQt5MultimediaWidgets.a libQt5PrintSupport.a libQt5Script.a libQt5UiTools.a libQt5Xml.alibQt53DCore.la libQt5Bluetooth.la libQt5Designer.la libQt5MultimediaWidgets.la libQt5PrintSupport.la libQt5Script.la libQt5UiTools.la libQt5Xml.lalibQt53DCore.prl libQt5Bluetooth.prl libQt5Designer.prl libQt5MultimediaWidgets.prl libQt5PrintSupport.prl libQt5Script.prl libQt5UiTools.prl libQt5XmlPatterns.alibQt53DInput.a libQt5Bootstrap.a libQt5EglDeviceIntegration.a libQt5Network.a libQt5Qml.a libQt5ScriptTools.a libQt5WaylandClient.a libQt5XmlPatterns.lalibQt53DInput.la libQt5Bootstrap.la libQt5EglDeviceIntegration.la libQt5Network.la libQt5QmlDevTools.a libQt5ScriptTools.la libQt5WaylandClient.la libQt5XmlPatterns.prllibQt53DInput.prl libQt5Bootstrap.prl libQt5EglDeviceIntegration.prl libQt5Network.prl libQt5QmlDevTools.la libQt5ScriptTools.prl libQt5WaylandClient.prl libQt5Xml.prllibQt53DLogic.a libQt5CLucene.a libQt5Gui.a libQt5Nfc.a libQt5QmlDevTools.prl libQt5SerialBus.a libQt5WebChannel.a libqtharfbuzzng.alibQt53DLogic.la libQt5CLucene.la libQt5Gui.la libQt5Nfc.la libQt5Qml.la libQt5SerialBus.la libQt5WebChannel.la libqtharfbuzzng.prllibQt53DLogic.prl libQt5CLucene.prl libQt5Gui.prl libQt5Nfc.prl libQt5Qml.prl libQt5SerialBus.prl libQt5WebChannel.prl libxcb-static.alibQt53DQuick.a libQt5Concurrent.a libQt5Help.a libQt5OpenGL.a libQt5Quick.a libQt5SerialPort.a libQt5WebSockets.a libxcb-static.prllibQt53DQuickInput.a libQt5Concurrent.la libQt5Help.la libQt5OpenGLExtensions.a libQt5Quick.la libQt5SerialPort.la libQt5WebSockets.la pkgconfiglibQt53DQuickInput.la libQt5Concurrent.prl libQt5Help.prl libQt5OpenGLExtensions.la libQt5QuickParticles.a libQt5SerialPort.prl libQt5WebSockets.prllibQt53DQuickInput.prl libQt5Core.a libQt5Location.a libQt5OpenGLExtensions.prl libQt5QuickParticles.la libQt5Sql.a libQt5Widgets.a
具体过程如图
- Qt 5 linux 编译选项
- Linux内核编译选项-5
- LINUX内核编译选项-5
- Qt交叉编译配置选项
- QT 怎样添加编译选项
- Linux内核编译选项
- omap3 linux编译选项
- [Linux]GCC编译选项
- linux 内核编译选项
- linux编译选项
- gcc编译选项 -- linux
- Linux编译选项
- Qt程序依赖库编译选项
- Qt程序依赖库编译选项
- Qt程序依赖库编译选项
- QT中增加C++11编译选项
- 修改linux内核编译选项
- 编译Linux内核留意选项
- 虚拟机VirtualBox中安装linux系统
- 网页简单布局-混合布局
- Mysql编程之游标基本概念
- sqlserver中判断表是否存在
- mongodb 备份 还原 导出 导入
- Qt 5 linux 编译选项
- js解析json js获取json里面的某个节点的数据 js解析json数据
- Sympy的使用
- SSL握手过程
- 7种排序算法的实现示例
- android 中通用加载失败 网络错误组件
- 解决 sudo ldconfig /sbin/ldconfig.real: xxx 不是符号连接
- Handler的工作原理
- 栈和队列