Cross compile for raspi outputs an "incompatible" error.
I have used the yocto to make a SDK to develop my raspi2. I have followed the qt wiki to configure the Qt creator. If I compile the example by sourcing the Qt cross-build environment, everything is OK.
But when I use the configured Qt creator to build it, the "incompatible" error comes out.Here is the error message:
/usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: skipping incompatible /home/max/project/poky-sdk/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/usr/lib/libQt5Widgets.so when searching for -lQt5Widgets /usr/lib64/gcc/x86_64-suse-linux/4.8/../../../../x86_64-suse-linux/bin/ld: cannot find -lQt5Widgets
I found that Qt creator use my system's ld, how to change it to the SDK's ld.
Did you make a Kit with the Qt version you cross-compiled ?
Yes, kit's setting is here:
@doodle Please upload the image to sharing service and post the link here: the image is not visible.
The error message you posted says that you're using your host x86_64 tool chain (compiler/linker) instead of the tool chain for raspi. Most probably your Kit is configured wrongly - check the selected compiler there.
I use the cross compiler built by yocto, Qt creator configuration is here:
and there is no linker option in the Qt creator.
I change the makefile's
LINKmanually to the sdk's cross compiler, and set some flags, everything is OK. So now my question is how to set these things correctly with the Qt creator.
BTW, as you can see above, I've configure the right compiler and use the right kits for the project, but things go wrong.
@doodle Please show the "Kits" tab after selecting the correct Kit. Are you sure you selected the Kit in QtCreator to build the project? The Kit you're using for cross compilation must use that compiler.
@doodle One more note: you should select gcc not g++ as compiler.
Did you try to do delete the build folder, run qmake and do a complete rebuild?
@jsulm Yes, I delete the whole build directory.
The makefile is bit strange, the
CXXdon't change to the compiler I've set.
####### Compiler, tools and options CC = gcc CXX = g++ DEFINES = -DQT_QML_DEBUG -DQT_WIDGETS_LIB -DQT_GUI_LIB -DQT_CORE_LIB CFLAGS = -pipe -g -Wall -W -D_REENTRANT -fPIC $(DEFINES) CXXFLAGS = -pipe -g -std=gnu++11 -Wall -W -D_REENTRANT -fPIC $(DEFINES) INCPATH = -I../window -I. -I../../poky-sdk/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/usr/include/qt5 -I../../poky-sdk/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/usr/include/qt5/QtWidgets -I../../poky-sdk/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/usr/include/qt5/QtGui -I../../poky-sdk/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/usr/include/qt5/QtCore -I. -I. -I../../poky-sdk/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/usr/lib/qt5/mkspecs/linux-g++ QMAKE = /home/max/project/poky-sdk/sysroots/x86_64-pokysdk-linux/usr/bin/qt5/qmake DEL_FILE = rm -f CHK_DIR_EXISTS= test -d MKDIR = mkdir -p COPY = cp -f COPY_FILE = cp -f COPY_DIR = cp -f -R INSTALL_FILE = install -m 644 -p INSTALL_PROGRAM = install -m 755 -p INSTALL_DIR = cp -f -R DEL_FILE = rm -f SYMLINK = ln -f -s DEL_DIR = rmdir MOVE = mv -f TAR = tar -cf COMPRESS = gzip -9f DISTNAME = window1.0.0 DISTDIR = /home/max/project/qt5/build-window-yocto_raspi-Debug/.tmp/window1.0.0 LINK = g++ LFLAGS = LIBS = $(SUBLIBS) -L/home/max/project/poky-sdk/sysroots/cortexa7hf-neon-vfpv4-poky-linux-gnueabi/usr/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lpthread AR = ar cqs RANLIB = SED = sed STRIP = strip
OK, I finally find the problem, the default qmake mkspecs is linux-g++ which is totally wrong, so I manually change it to the
...../qt5/mkspecs/linux-oe-g++/, now I build the project smoothly!
Maybe this mistake has somthing to do with the yocto's "meta-qt5" layer.