error: undefined reference to 'cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
-
sir,
i cross compiled opencv 4.1.2 in my ubuntu pc (16.04) using cmake gui
in my cmake set windowi given
operating system arm-linux
processor arm
compilers:
c: /opt/FriendlyARM/toolchain/4.9.3/bin/arm-cortexa9-linux-gnueabihf-cc
c++: /opt/FriendlyARM/toolchain/4.9.3/bin/arm-cortexa9-linux-gnueabihf-c++
target /opt/FriendlyARM/toolchain/4.9.3/arm-cortexa9-linux-gnueabihf/sys-root
CMAKE _INSTALL_PRIFIX=usr/local/arm/openc-arm
after cross compilation#------------------------------------------------- # # Project created by QtCreator 2021-03-09T14:11:00 # #------------------------------------------------- QT += core gui greaterThan(QT_MAJOR_VERSION, 4): QT += widgets TARGET = opencv3 TEMPLATE = app CONFIG += c++11 # The following define makes your compiler emit warnings if you use # any feature of Qt which as been marked as deprecated (the exact warnings # depend on your compiler). Please consult the documentation of the # deprecated API in order to know how to port your code away from it. DEFINES += QT_DEPRECATED_WARNINGS # You can also make your code fail to compile if you use deprecated APIs. # In order to do so, uncomment the following line. # You can also select to disable deprecated APIs only up to a certain version of Qt. #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0 INCLUDEPATH += /usr/local/arm/opencv-arm/include/opencv4 \ ./resources LIBS += -L/usr/local/arm/opencv-arm/lib -I/usr/local/arm/opencv-arm/include/opencv4 -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_objdetect SOURCES += \ main.cpp \ mainwindow.cpp HEADERS += \ mainwindow.h FORMS += \ mainwindow.ui INSTALLS = target target.files = opencv3 target.path = /home/pi
compilation output:-
16:50:30: Running steps for project opencv...
16:50:30: Configuration unchanged, skipping qmake step.
16:50:30: Starting: "/usr/bin/make"
arm-linux-gnueabihf-g++ -fuse-ld=gold -mfloat-abi=hard --sysroot=/opt/rootfs-s5p4418 -Wl,-rpath,/usr/local/Trolltech/Qt-5.10.0-nexell32/lib -o opencv3 main.o mainwindow.o moc_mainwindow.o -L/usr/nexell-libs/lib32 -L/usr/local/arm/opencv-arm/lib -I/usr/local/arm/opencv-arm/include/opencv4 -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_objdetect -L/opt/rootfs-s5p4418/usr/local/Trolltech/Qt-5.10.0-nexell32/lib -lQt5Widgets -lQt5Gui -lQt5Core -lGLESv2 -lpthread
../opencv/mainwindow.cpp:22: error: undefined reference to 'cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)'
collect2: error: ld returned 1 exit status
Makefile:251: recipe for target 'opencv3' failed
make: *** [opencv3] Error 1 -
@swansorter said in error: undefined reference to 'cv::imread(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, int)':
LIBS += -L/usr/local/arm/opencv-arm/lib -I/usr/local/arm/opencv-arm/include/opencv4 -lopencv_core -lopencv_imgcodecs -lopencv_imgproc -lopencv_objdetect
What is this?! Why do you add include folder to the libs search paths?
What are the names of the libs inside /usr/local/arm/opencv-arm/lib? -
@swansorter Did you try full rebuild after fixing pro file?
-
@swansorter The m
-
@swansorter Actually you should install the libs/headers in your sysroot
-
@swansorter Simply copy them to your sysroot...
-
@swansorter Libs to: /opt/rootfs-s5p4418/usr/lib
Include files to: /opt/rootfs-s5p4418/usr/include -
@swansorter yes