在编译飞凌嵌入式给出的i.MX6Q Qt5.6+Linux4.1.15 的测试程序 ping时,报错:
root@ubuntu:/work/qt5.6/ping# qmake
root@ubuntu:/work/qt5.6/ping# make
arm-poky-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi -c -pipe -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/data/fsl-release-bsp/build-x11/tmp/work/x86_64-nativesdk-pokysdk-linux/meta-environment-imx6qsabresd/1.0-r8=/usr/src/debug/meta-environment-imx6qsabresd/1.0-r8 -fdebug-prefix-map=/data/fsl-release-bsp/build-x11/tmp/sysroots/x86_64-linux= -fdebug-prefix-map=/data/fsl-release-bsp/build-x11/tmp/sysroots/x86_64-nativesdk-pokysdk-linux= -O2 -DLINUX=1 -std=gnu++0x -Wall -W -fPIC -DQT_NO_DEBUG -DQT_GUI_LIB -DQT_CORE_LIB -I. -I. -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5 -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtGui -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtCore -I. -I/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-oe-g++ -o main.o main.cpp
In file included from main.cpp:1:0:
mainwindow.h:4:23: fatal error: QMainWindow: No such file or directory
compilation terminated.
make: *** [main.o] Error 1
经搜索,最后在 stackflow上找到答案:
在ping.pro文件末尾加入如下一行:
QT += widgets network gui
问题解决,编译输出如下:
root@ubuntu:/work/qt5.6/ping# qmake
root@ubuntu:/work/qt5.6/ping# make
arm-poky-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi -c -pipe -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/data/fsl-release-bsp/build-x11/tmp/work/x86_64-nativesdk-pokysdk-linux/meta-environment-imx6qsabresd/1.0-r8=/usr/src/debug/meta-environment-imx6qsabresd/1.0-r8 -fdebug-prefix-map=/data/fsl-release-bsp/build-x11/tmp/sysroots/x86_64-linux= -fdebug-prefix-map=/data/fsl-release-bsp/build-x11/tmp/sysroots/x86_64-nativesdk-pokysdk-linux= -O2 -DLINUX=1 -std=gnu++0x -Wall -W -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5 -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtWidgets -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtGui -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtNetwork -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtCore -I. -I. -I/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-oe-g++ -o main.o main.cpp
arm-poky-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi -c -pipe -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/data/fsl-release-bsp/build-x11/tmp/work/x86_64-nativesdk-pokysdk-linux/meta-environment-imx6qsabresd/1.0-r8=/usr/src/debug/meta-environment-imx6qsabresd/1.0-r8 -fdebug-prefix-map=/data/fsl-release-bsp/build-x11/tmp/sysroots/x86_64-linux= -fdebug-prefix-map=/data/fsl-release-bsp/build-x11/tmp/sysroots/x86_64-nativesdk-pokysdk-linux= -O2 -DLINUX=1 -std=gnu++0x -Wall -W -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5 -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtWidgets -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtGui -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtNetwork -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtCore -I. -I. -I/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-oe-g++ -o mainwindow.o mainwindow.cpp
arm-poky-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi -c -pipe -O2 -pipe -g -feliminate-unused-debug-types -fdebug-prefix-map=/data/fsl-release-bsp/build-x11/tmp/work/x86_64-nativesdk-pokysdk-linux/meta-environment-imx6qsabresd/1.0-r8=/usr/src/debug/meta-environment-imx6qsabresd/1.0-r8 -fdebug-prefix-map=/data/fsl-release-bsp/build-x11/tmp/sysroots/x86_64-linux= -fdebug-prefix-map=/data/fsl-release-bsp/build-x11/tmp/sysroots/x86_64-nativesdk-pokysdk-linux= -O2 -DLINUX=1 -std=gnu++0x -Wall -W -fPIC -DQT_NO_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I. -I. -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5 -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtWidgets -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtGui -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtNetwork -isystem /opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/include/qt5/QtCore -I. -I. -I/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-oe-g++ -o moc_mainwindow.o moc_mainwindow.cpp
arm-poky-linux-gnueabi-g++ -march=armv7-a -mfpu=neon -mfloat-abi=hard -mcpu=cortex-a9 --sysroot=/opt/fsl-imx-x11/4.1.15-2.1.0/sysroots/cortexa9hf-neon-poky-linux-gnueabi -Wl,-O1 -Wl,--hash-style=gnu -Wl,--as-needed -Wl,-O1 -o ping main.o mainwindow.o moc_mainwindow.o -lQt5Widgets -lQt5Gui -lQt5Network -lQt5Core -lGLESv2 -lEGL