Linking open-cv objects to locally installed opencv on Pi with Crosscompile setup

Viewed 21

Working for over two month on the problem, main question: what to check or adjust? Since I'm familiar with the setup I've started another one, but this time the build-setup won't work, whatever I change.

Here is the setup:

  1. Raspberry Pi with a 5.4.74 somewhat Kernel (a buster version I assume), lite (no x-Server/Desktop)
  2. Crosscompiled Qt 5.15.4 and set up a remote Qt-Creator to build apps - Qt-only Applications build, deploy, and remote-debug flawlessly fine
  3. Build OpenCV 4.5 on the pi and installed it at /usr/local/lib
  4. Synced the sysroot (/usr, /usr/lib, /usr/local/lib) to the Host

Once I've start to Include opencv, first the Compiler, that the linker seems to have issues this time and having issues to even find the basic symbols in libopencv_core.so: (at the very end is the first error)

> /home/patrick/rpi-qt/tools/cross-pi-gcc-8.3.0-2/bin/../libexec/gcc/arm-linux-gnueabihf/8.3.0/collect2
> -plugin /home/patrick/rpi-qt/tools/cross-pi-gcc-8.3.0-2/bin/../libexec/gcc/arm-linux-gnueabihf/8.3.0/liblto_plugin.so
> -plugin-opt=/home/patrick/rpi-qt/tools/cross-pi-gcc-8.3.0-2/bin/../libexec/gcc/arm-linux-gnueabihf/8.3.0/lto-wrapper
> -plugin-opt=-fresolution=/tmp/cc9JUQx6.res
> -plugin-opt=-pass-through=-lgcc_s
> -plugin-opt=-pass-through=-lgcc
> -plugin-opt=-pass-through=-lc
> -plugin-opt=-pass-through=-lgcc_s
> -plugin-opt=-pass-through=-lgcc
> --sysroot=/home/patrick/rpi-qt/sysroot/
> --eh-frame-hdr
> -dynamic-linker /lib/ld-linux-armhf.so.3
> -X
> -m armelf_linux_eabi
> -o ICCS_V1 /home/patrick/rpi-qt/sysroot/usr/lib/crt1.o /home/patrick/rpi-qt/sysroot/usr/lib/crti.o
> /home/patrick/rpi-qt/tools/cross-pi-gcc-8.3.0-2/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/crtbegin.o
> -L/home/patrick/rpi-qt/sysroot/usr/lib/arm-linux-gnueabihf 
> -L/home/patrick/rpi-qt/tools/cross-pi-gcc-8.3.0-2/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0
> -L/home/patrick/rpi-qt/tools/cross-pi-gcc-8.3.0-2/bin/../lib/gcc
> -L/home/patrick/rpi-qt/tools/cross-pi-gcc-8.3.0-2/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/lib
> -L/home/patrick/rpi-qt/sysroot/lib
> -L/home/patrick/rpi-qt/sysroot/usr/lib
> -rpath /usr/local/qt5.15/lib
> -rpath-link /home/patrick/rpi-qt/sysroot/usr/lib/arm-linux-gnueabihf
> -rpath-link /home/patrick/rpi-qt/sysroot/lib/arm-linux-gnueabihf aux.o camcapture.o iccscam.o iccsimgprocessing.o imgbasicaux.o
> innosentcalibreport.o main.o iccsmainwindow.o scalarhistorygraph.o
> qrc_resources.o moc_iccscam.o moc_iccsimgprocessing.o
> moc_iccsmainwindow.o moc_innosentcalibreport.o
> moc_scalarhistorygraph.o
> -rpath-link=/usr/local/lib -lopencv_core -lopencv_highgui -lopencv_imgcodec -lopencv_imgproc -lopencv_videoio /home/patrick/rpi-qt/qt5.15/lib/libQt5Widgets.so
> /home/patrick/rpi-qt/qt5.15/lib/libQt5Gui.so
> /home/patrick/rpi-qt/qt5.15/lib/libQt5Network.so
> /home/patrick/rpi-qt/qt5.15/lib/libQt5Core.so
> -lGLESv2 -lpthread -lstdc++ -lm -lgcc_s -lgcc -lc -lgcc_s -lgcc /home/patrick/rpi-qt/tools/cross-pi-gcc-8.3.0-2/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/crtend.o
> /home/patrick/rpi-qt/sysroot/usr/lib/crtn.o
> /home/patrick/rpi-qt/tools/cross-pi-gcc-8.3.0-2/bin/../lib/gcc/arm-linux-gnueabihf/8.3.0/../../../../arm-linux-gnueabihf/bin/ld:
> camcapture.o: in function 'CamCapture::CamCapture()':
> /home/patrick/workspace/gitlab.iccs/iccs/build-ICCS_V1-Raspi4_iccs-Debug/../ICCS_V1/camcapture.cpp:6:
> undefined reference to `cv::Mat::Mat()'

and then following again some more of the missing references.

The opencv install works flawlessly when building an application locally (Remote-X of the same project with qt-creator) and prooved that all depending libs are available and fine, so the basics of the kit setup is fine.

The cv-libs are available after syncing the rootfile system after install.

I'm not really into the details behind QMake and CMake, but the order of the arguments depend not on the one in the .pro setup.

If I change the name of the included libs, qmake states they are not to find, so at the beginning they are definitely pointing to the correct files.

Statements like -Wl, -rpath etc. did not affect anything and have not been used in the older setups. I've tried to find any structural difference in an old setup with opencv 4.3 and Qt 5.15.2 on another system, but opencv is also at /usr/local/lib and the .pro setup is identical. Also the kit-setup have not been any different.

My main Question: what should I check or where do I have to look for details or differences.

heres also the .pro file:

QT       += core gui network
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
CONFIG += c++11
    
SOURCES += \
...
HEADERS += \
...

FORMS += \
...

RESOURCES += \
    resources.qrc

DISTFILES += \
...

adding this changed it from a compiler to a linker problem:

INCLUDEPATH += /usr/include/opencv4

I assume it is just using the header of the locally installed opencv and they work

INCLUDEPATH += /usr/local/include/opencv4
    
LIBS += -lopencv_core -lopencv_highgui -lopencv_imgcodecs -lopencv_imgproc -lopencv_videoio
INSTALLS += target

The smalles hint left is that the compiler error (if it is not picking up the cv-header of the host-machine) was not pointed to the sysroot location, rather a real /usr/local/include/opencv4 which does not exist. So maybe that wrong sysroot apply took also place in the linking stage. btw: what is that collect2 call instead of a proper linker call?

Thanks for any help.

0 Answers
Related