效果视频https://live.csdn.net/v/258035
一、下载qt源码
https://download.qt.io/archive/qt/5.15/5.15.2/single/qt-everywhere-src-5.15.2.tar.xz
二、安装xcb依赖环境
sudo apt-get install '^libxcb.*-dev' libx11-xcb-dev libglu1-mesa-dev libxrender-dev libxi-dev libxkbcommon-dev libxkbcommon-x11-dev
三、configure
解压源码以后,进入源码目录打开终端,新建一个build文件夹,在里面再新建一个autoconfig.sh 并赋予可执行权限
../configure -recheck-all -release -extprefix "/home/firefly/Qt5.12.8" -xplatform linux-aarch64-gnu-g++ -no-opengl -no-openssl -nomake tests -no-compile-examples -nomake examples -gif -ico -qt-libpng -qt-libjpeg -qt-sqlite -opengl es2 -xcb -xcb-xlib -bundled-xcb-xinput
安装qt-creator
sudo apt-get install qt5-default qtcreator -y
qt之库编译错误:qdbusmarshaller.cpp:(.text+0x0): `QDBusMarshaller::append(QString const&)'被多次定义
错误描述
.obj/qdbusmarshaller.o:在函数‘QDBusMarshaller::append(QString const&)’中:
qdbusmarshaller.cpp:(.text+0x0): `QDBusMarshaller::append(QString const&)'被多次定义
.obj/qdbusargument.o:qdbusargument.cpp:(.text+0x1b90):第一次在此定义
.obj/qdbusmarshaller.o:在函数‘QDBusMarshaller::open(QDBusMarshaller&, int, char const*)’中:
qdbusmarshaller.cpp:(.text+0xc0): `QDBusMarshaller::open(QDBusMarshaller&, int, char const*)'被多次定义
.obj/qdbusargument.o:qdbusargument.cpp:(.text+0x1c80):第一次在此定义
.obj/qdbusmarshaller.o:在函数‘QDBusMarshaller::beginCommon(int, char const*)’中:
qdbusmarshaller.cpp:(.text+0x180): `QDBusMarshaller::beginCommon(int, char const*)'被多次定义
.obj/qdbusargument.o:qdbusargument.cpp:(.text+0x1d40):第一次在此定义
.obj/qdbusmarshaller.o:在函数‘QDBusMarshaller::endCommon()’中:
qdbusmarshaller.cpp:(.text+0x220): `QDBusMarshaller::endCommon()'被多次定义
.obj/qdbusargument.o:qdbusargument.cpp:(.text+0x2380):第一次在此定义
.obj/qdbusmarshaller.o:在函数‘QDBusMarshaller::close()’中:
qdbusmarshaller.cpp:(.text+0x230): `QDBusMarshaller::close()'被多次定义
错误原因
这是由于在源码文件qtbase/src/dbus/qdbusargument.cpp中有以下代码:
// for optimization purposes, we include the marshallers here
#include "qdbusmarshaller.cpp"
#include "qdbusdemarshaller.cpp
这是已经包含了qdbusmarshaller.cpp。但是在工程文件qtbase/src/dbus/dbus.pro中同时又包含以下代码:
SOURCES += qdbusconnection.cpp \
qdbusconnectioninterface.cpp \
qdbuserror.cpp \
qdbusintegrator.cpp \
qdbusmessage.cpp \
qdbusserver.cpp \
qdbusabstractinterface.cpp \
qdbusinterface.cpp \
qdbusxmlparser.cpp \
qdbusutil.cpp \
qdbusintrospection.cpp \
qdbusabstractadaptor.cpp \
qdbusinternalfilters.cpp \
qdbusmetaobject.cpp \
qdbusxmlgenerator.cpp \
qdbusmisc.cpp \
qdbusargument.cpp \
qdbusreply.cpp \
qdbusmetatype.cpp \
qdbusextratypes.cpp \
qdbusmarshaller.cpp \
qdbuscontext.cpp \
qdbuspendingcall.cpp \
qdbuspendingreply.cpp \
qdbus_symbols.cpp \
qdbusservicewatcher.cpp \
qdbusunixfiledescriptor.cpp \
qdbusvirtualobject.cpp
解决方法
可以删除qtbase/src/dbus/dbus.pro文件中SOURCES对qdbusmarshaller.cpp的引用,例如:
SOURCES += qdbusconnection.cpp \
qdbusconnectioninterface.cpp \
qdbuserror.cpp \
qdbusintegrator.cpp \
qdbusmessage.cpp \
qdbusserver.cpp \
qdbusabstractinterface.cpp \
qdbusinterface.cpp \
qdbusxmlparser.cpp \
qdbusutil.cpp \
qdbusintrospection.cpp \
qdbusabstractadaptor.cpp \
qdbusinternalfilters.cpp \
qdbusmetaobject.cpp \
qdbusxmlgenerator.cpp \
qdbusmisc.cpp \
qdbusargument.cpp \
qdbusreply.cpp \
qdbusmetatype.cpp \
qdbusextratypes.cpp \
qdbusmarshaller.cpp \ /* 手动删除本行 */
qdbuscontext.cpp \
qdbuspendingcall.cpp \
qdbuspendingreply.cpp \
qdbus_symbols.cpp \
qdbusservicewatcher.cpp \
qdbusunixfiledescriptor.cpp \
qdbusvirtualobject.cpp
load(qt_module)
qt之库编译错误:qmutex_linux.cpp:multiple definition of ‘QBasicMutex::lockInternal(int)’
错误描述
.obj/qmutex_linux.o: In function QBasicMutex::lockInternal()': qmutex_linux.cpp:(.text+0x0): multiple definition ofQBasicMutex::lockInternal()'
.obj/qmutex.o:qmutex.cpp:(.text+0x150): first defined here
.obj/qmutex_linux.o: In function QBasicMutex::lockInternal(int)': qmutex_linux.cpp:(.text+0x60): multiple definition ofQBasicMutex::lockInternal(int)'
.obj/qmutex.o:qmutex.cpp:(.text+0x2a8): first defined here
.obj/qmutex_linux.o: In function QBasicMutex::unlockInternal()': qmutex_linux.cpp:(.text+0x1e0): multiple definition ofQBasicMutex::unlockInternal()'
.obj/qmutex.o:qmutex.cpp:(.text+0x550): first defined here
collect2: error: ld returned 1 exit status
Makefile:1241: recipe for target '../../lib/libQt5Core.so.5.13.0' failed
make[3]: *** [../../lib/libQt5Core.so.5.13.0] Error 1
make[3]: Leaving directory '/home/firefly/Downloads/build_qt/qtbase/src/corelib'
Makefile:226: recipe for target 'sub-corelib-make_first' failed
make[2]: *** [sub-corelib-make_first] Error 2
make[2]: Leaving directory '/home/firefly/Downloads/build_qt/qtbase/src'
Makefile:50: recipe for target 'sub-src-make_first' failed
make[1]: *** [sub-src-make_first] Error 2
make[1]: Leaving directory '/home/firefly/Downloads/build_qt/qtbase'
Makefile:63: recipe for target 'module-qtbase-make_first' failed
make: *** [module-qtbase-make_first] Error 2
错误原因
这是由于在源码文件qtbase/src/corelib/thread/qmutex.cpp中有以下代码:
#ifdef QT_LINUX_FUTEX
# include "qmutex_linux.cpp"
#elif defined(Q_OS_MAC)
# include "qmutex_mac.cpp"
#elif defined(Q_OS_WIN)
# include "qmutex_win.cpp"
#else
# include "qmutex_unix.cpp"
#endif
这是为了兼容不同平台的代码。但是在工程文件qtbase/src/corelib/thread/thread.pri中同时又包含以下代码:
SOURCES += \
thread/qatomic.cpp \
thread/qmutex.cpp \
thread/qreadwritelock.cpp \
thread/qsemaphore.cpp \
thread/qthreadpool.cpp \
thread/qthreadstorage.cpp
win32 {
SOURCES += \
thread/qmutex_win.cpp \
thread/qwaitcondition_win.cpp
} else {
darwin {
SOURCES += thread/qmutex_mac.cpp
} else: linux {
SOURCES += thread/qmutex_linux.cpp
} else {
SOURCES += thread/qmutex_unix.cpp
}
SOURCES += thread/qwaitcondition_unix.cpp
}
这两个地方对文件qmutex_linux.cpp进行了重复包含,所以造成了在编译期间检测到两个文件中有相同的符号。
解决方法
可以删除qtbase/src/corelib/thread/thread.pri文件中SOURCES对qmutex_linux.cpp的引用,例如:
SOURCES += \
thread/qatomic.cpp \
thread/qmutex.cpp \
thread/qreadwritelock.cpp \
thread/qsemaphore.cpp \
thread/qthreadpool.cpp \
thread/qthreadstorage.cpp
win32 {
SOURCES += \
thread/qmutex_win.cpp \ /* 手动删除本行 */
thread/qwaitcondition_win.cpp
} else {
darwin {
SOURCES += thread/qmutex_mac.cpp /* 手动删除本行 */
} else: linux {
SOURCES += thread/qmutex_linux.cpp /* 手动删除本行 */
} else {
SOURCES += thread/qmutex_unix.cpp /* 手动删除本行 */
}
SOURCES += thread/qwaitcondition_unix.cpp
}
qt之库编译错误:xfixes.c:(.text+0x4e):对‘xcb_send_request’未定义的引用
qt之库编译错误:qmutex_linux.cpp:multiple definition of ‘QBasicMutex::lockInternal(int)’
qt之库编译错误:src/client/qwayland-wayland.h: No such file or directory
qt之库编译错误:qxcbkeyboard.cpp:(.text+0x25c):对‘QXkbCommon::xxxxxx(xxx)’未定义的引用
qt之linux库编译