Hello,
I was able to compile simple QT app for RaspberryPi2 in the Ubuntu environment, meaning that required settings are already set (kits, debugger, compiler etc). However when this app uses OpenCV libraries I get the error below:
/usr/local/lib/libopencv_core.so:-1: error: file not recognized: File format not recognized
error: collect2: error: ld returned 1 exit status
Here is the .pro file:
QT += core
QT -= gui
CONFIG += c++11
TARGET = untitled
CONFIG += console
CONFIG -= app_bundle
TEMPLATE = app
SOURCES += main.cpp
INCLUDEPATH += /usr/local/include
LIBS += -L/usr/local/lib
LIBS += -lopencv_core
LIBS += -lopencv_imgproc
LIBS += -lopencv_highgui
LIBS += -lopencv_ml
LIBS += -lopencv_video
LIBS += -lopencv_features2d
LIBS += -lopencv_objdetect
LIBS += -lopencv_flann
LIBS += -lopencv_imgcodecs
QT Build & Run Settings:
Device Type: Generic Linux Type
Sysroot: /home/mustafa/raspi/sysroot
Compiler: /home/mustafa/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++
Debugger: /home/mustafa/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian-x64/bin/arm-linux-gnueabihf-gdb
Qt version: Qt 5.6.1 (/home/mustafa/raspi/qt5/bin/qmake)
CMake Tool: System Cmake at /usr/bin/cmake
OpenCV Physical Dirs:
Ubuntu Desktop Build: /usr/local/lib
OpenCV Cross Compile Build: /home/mustafa/raspi/opencv/platforms/linux/build_hardfp/lib
RasperryPi2 Build: /home/mustafa/raspi/sysroot/usr/local/lib (Copied built opencv libs from build_hardfp above to this folder so QT can find them under usr/local/lib)
Eventhoug I cross compiled OpenCV from source for Raspberry Pi2, I can not compile a simple app for Raspberry Pi2 using OpenCV under Ubuntu.
Lastly, here is the compile output:
10:00:39: Running steps for project untitled…
10:00:39: Starting: “/usr/bin/make” clean
rm -f main.o
rm -f *~ core *.core
10:00:39: The process “/usr/bin/make” exited normally.
10:00:39: Configuration unchanged, skipping qmake step.
10:00:39: Starting: “/usr/bin/make”
/home/mustafa/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ -c -pipe -march=armv7-a -marm -mthumb-interwork -mfpu=neon-vfpv4 -mtune=cortex-a7 -mabi=aapcs-linux -mfloat-abi=hard --sysroot=/home/mustafa/raspi/sysroot -O2 -std=gnu++0x -Wall -W -D_REENTRANT -fPIC -DQT_NO_DEBUG -DQT_CORE_LIB -I…/untitled -I. -I…/raspi/sysroot/opt/vc/include -I…/raspi/sysroot/opt/vc/include/interface/vcos -I…/raspi/sysroot/opt/vc/include/interface/vcos/pthreads -I…/raspi/sysroot/opt/vc/include/interface/vmcs_host/linux -I/usr/local/include -I…/raspi/qt5pi/include -I…/raspi/qt5pi/include/QtCore -I. -I…/raspi/qt5/mkspecs/devices/linux-rasp-pi2-g++ -o main.o …/untitled/main.cpp
/home/mustafa/raspi/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ -Wl,-rpath-link,/home/mustafa/raspi/sysroot/opt/vc/lib -Wl,-rpath-link,/home/mustafa/raspi/sysroot/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/home/mustafa/raspi/sysroot/lib/arm-linux-gnueabihf -mfloat-abi=hard --sysroot=/home/mustafa/raspi/sysroot -Wl,-O1 -Wl,-rpath,/usr/local/qt5pi/lib -o untitled main.o -L/usr/local/lib -lopencv_core -lopencv_imgproc -lopencv_highgui -lopencv_ml -lopencv_video -lopencv_features2d -lopencv_objdetect -lopencv_flann -lopencv_imgcodecs -L/home/mustafa/raspi/qt5pi/lib -lQt5Core -lpthread
/usr/local/lib/libopencv_core.so: file not recognized: File format not recognized
collect2: error: ld returned 1 exit status
make: *** [untitled] Error 1
10:00:44: The process “/usr/bin/make” exited with code 2.
Error while building/deploying project untitled (kit: qt560rpi2)
When executing step “Make”
10:00:44: Elapsed time: 00:06.
Can anyone tell me whats wrong?