QT5交叉编译出现"undefined reference to `qt_version_tag'"的解决方法

如下图所示:

根据交叉编译的配置,我觉得我的qmake版本是没有配置错误的。

QT5交叉编译出现

输出的Complie Output的log如下:

22:33:46: Running steps for project untitled...
22:33:46: Starting: "/usr/bin/make" clean
rm -f moc_mainwindow.cpp
rm -f ui_mainwindow.h
rm -f main.o mainwindow.o moc_mainwindow.o
rm -f *~ core *.core
22:33:46: The process "/usr/bin/make" exited normally.
22:33:46: Starting: "/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/qmake" /home/yuanxin/Desktop/Hello/HelloQT/untitled/untitled.pro -r -spec linux-g++ CONFIG+=debug
22:33:46: The process "/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/qmake" exited normally.
22:33:46: Starting: "/usr/bin/make" 
/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/uic mainwindow.ui -o ui_mainwindow.h
g++ -c -pipe -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5 -isystem /opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtWidgets -isystem /opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtGui -isystem /opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtCore -I. -I. -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-g++ -o main.o main.cpp
g++ -c -pipe -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5 -isystem /opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtWidgets -isystem /opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtGui -isystem /opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtCore -I. -I. -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-g++ -o mainwindow.o mainwindow.cpp
/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/moc -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-g++ -I/home/yuanxin/Desktop/Hello/HelloQT/untitled -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5 -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtWidgets -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtGui -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtCore -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/c++/5.3.0 -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/c++/5.3.0/arm-poky-linux-gnueabi -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/c++/5.3.0/backward -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/x86_64-pokysdk-linux/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.3.0/include -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/gcc/arm-poky-linux-gnueabi/5.3.0/include -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/x86_64-pokysdk-linux/lib/arm-poky-linux-gnueabi/gcc/arm-poky-linux-gnueabi/5.3.0/include-fixed -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include mainwindow.h -o moc_mainwindow.cpp
g++ -c -pipe -g -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB -I. -isystem /opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5 -isystem /opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtWidgets -isystem /opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtGui -isystem /opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtCore -I. -I. -I/opt/fsl-imx-x11/4.1.15-2.0.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-g++ -o moc_mainwindow.o moc_mainwindow.cpp
g++  -o untitled main.o mainwindow.o moc_mainwindow.o   -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lpthread 
main.o:(.qtversion[qt_version_tag]+0x0): undefined reference to `qt_version_tag'
collect2: ld returned 1 exit status
make: *** [untitled] Error 1
22:33:51: The process "/usr/bin/make" exited with code 2.
Error while building/deploying project untitled (kit: iMX6 toolchain)
When executing step 'Make'

22:33:51: Elapsed time: 00:05.

但是到当前目录下交叉编译QT工程:

QT5交叉编译出现

首先确保当前的环境变量已经设置为交叉编译环境。

然后qmake  xxx.pro生成编译QT工程的Makefile。

接下来接着Make。

        这就很奇怪了,在QT GUI上明明是使用交叉编译的?GCC、GDB包括Kit工具链都是参考一些文档配置完成的,为什么就变成g++的方式去编译了呢??有人和我说是qmake的版本不对,但解决方法无果,后来我发现还有一种解决这个问题的方法,如下:

直接手动修改,就像用如上命令行编译的方式:

command:qmake

Arguments: xxx.pro

Working diretory(当前QT工程的路径):xxxxxxx

QT5交叉编译出现

再重新build即不会出现:undefined reference to `qt_version_tag这种问题。

如下:

QT5交叉编译出现



你可能感兴趣的:(QT软件开发)