Cross compiling OpenCV 4.9.0 for Raspberry Pi 64bit (latest bookworm OS)

Sysprogs forums Forums VisualGDB Cross compiling OpenCV 4.9.0 for Raspberry Pi 64bit (latest bookworm OS)

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
    Posts
  • #35848
    ptihanyi
    Participant

    Hello!

    Based on the description of VisualGDB (https://visualgdb.com/tutorials/raspberry/opencv/build/), I tried to cross-compile OpenCV 4.9.0 on Raspberry Pi 3 (latest Raspberry OS 64bit).
    Everything went fine until the translation, when the process was interrupted with the following error:

    FAILED: modules/videoio/CMakeFiles/opencv_videoio.dir/src/videoio_c.cpp.o
    c:\SysGCC\raspberry64\bin\aarch64-linux-gnu-g++.exe --sysroot=C:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot -DCVAPI_EXPORTS -DENABLE_PLUGINS -DHAVE_CAMV4L2 -DHAVE_DC1394_2 -DHAVE_FFMPEG -DHAVE_GSTREAMER -DHAVE_OBSENSOR -DHAVE_OBSENSOR_V4L2 -D_USE_MATH_DEFINES -D__OPENCV_BUILD=1 -D__STDC_CONSTANT_MACROS -D__STDC_FORMAT_MACROS -D__STDC_LIMIT_MACROS -IC:/projects/opencv-rpi/opencv-4.9.0/build/VisualGDB/Debug -IC:/projects/opencv-rpi/opencv-4.9.0/modules/videoio/include -IC:/projects/opencv-rpi/opencv-4.9.0/build/VisualGDB/Debug/modules/videoio -IC:/projects/opencv-rpi/opencv-4.9.0/modules/core/include -IC:/projects/opencv-rpi/opencv-4.9.0/modules/imgproc/include -IC:/projects/opencv-rpi/opencv-4.9.0/modules/imgcodecs/include -isystem c:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/usr/include -isystem c:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/usr/include/gstreamer-1.0 -isystem c:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/usr/include/aarch64-linux-gnu -isystem c:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/usr/include/glib-2.0 -isystem c:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/usr/lib/aarch64-linux-gnu/glib-2.0/include -isystem c:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/usr/include/orc-0.4 -fsigned-char -W -Wall -Wreturn-type -Wnon-virtual-dtor -Waddress -Wsequence-point -Wformat -Wformat-security -Wmissing-declarations -Wundef -Winit-self -Wpointer-arith -Wshadow -Wsign-promo -Wuninitialized -Wsuggest-override -Wno-delete-non-virtual-dtor -Wno-comment -Wimplicit-fallthrough=3 -Wno-strict-overflow -fdiagnostics-show-option -pthread -fomit-frame-pointer -ffunction-sections -fdata-sections -fvisibility=hidden -fvisibility-inlines-hidden -O3 -DNDEBUG -DNDEBUG -std=c++11 -fPIC -MD -MT modules/videoio/CMakeFiles/opencv_videoio.dir/src/videoio_c.cpp.o -MF modules\videoio\CMakeFiles\opencv_videoio.dir\src\videoio_c.cpp.o.d -o modules/videoio/CMakeFiles/opencv_videoio.dir/src/videoio_c.cpp.o -c C:/projects/opencv-rpi/opencv-4.9.0/modules/videoio/src/videoio_c.cpp
    In file included from c:\sysgcc\raspberry64\aarch64-linux-gnu\include\c++\12/bits/stl_algo.h:69,
    from c:\sysgcc\raspberry64\aarch64-linux-gnu\include\c++\12/algorithm:61,
    from C:/projects/opencv-rpi/opencv-4.9.0/modules/core/include/opencv2/core/base.hpp:55,
    from C:/projects/opencv-rpi/opencv-4.9.0/modules/core/include/opencv2/core.hpp:53,
    from C:/projects/opencv-rpi/opencv-4.9.0/modules/videoio/include/opencv2/videoio.hpp:46,
    from C:/projects/opencv-rpi/opencv-4.9.0/modules/videoio/src/precomp.hpp:57,
    from C:/projects/opencv-rpi/opencv-4.9.0/modules/videoio/src/videoio_c.cpp:5:
    c:\sysgcc\raspberry64\aarch64-linux-gnu\include\c++\12/cstdlib:75:15: fatal error: stdlib.h: No such file or directory
    75 | #include_next <stdlib.h>
    | ^~~~~~~~~~
    compilation terminated.

    After a long search I found this bug ticket: https://gitlab.kitware.com/cmake/cmake/-/issues/23013 and this forum topic: https://discourse.cmake.org/t/drive-letter-inconsistency -on-windows-between-find-path-and-implicit-include-directories/1221

    If we look at the compile command in the error message, it clearly includes the option “-isystem c:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/usr/include”.
    But if I list “C:\projects\opencv-rpi\opencv-4.9.0\build\VisualGDB\Debug\CMakeFiles\3.28.1-gc5d9601-dirty\CMakeCXXCompiler.cmake” I see this:
    set(CMAKE_CXX_IMPLICIT_INCLUDE_DIRECTORIES “C:/SysGCC/raspberry64/aarch64-linux-gnu/include/c++/12;C:/SysGCC/raspberry64/aarch64-linux-gnu/include/c++/12/backward; /lib/gcc/aarch64-linux-gnu/12/include;C:/SysGCC/raspberry64/lib/gcc/aarch64-linux-gnu/12/include-fixed;C:/SysGCC/raspberry64/aarch64-linux-gnu /include;C:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/usr/include/aarch64-linux-gnu;C:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/usr/include”)
    At the end of the line there is the entry “C:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/usr/include”, but the “C” is capitalized!

    This is also the case with the “CMakeCCompiler.cmake” file.

    I tried the trick of deleting “build.ninja” and rewriting “C:/SysGCC/raspberry64/aarch64-linux-gnu/sysroot/usr/include” in “CMakeCCompiler.cmake” and “CMakeCXXCompiler.cmake” “- entry, change “C” to “c”.
    I reloaded the project, started the build process and it completed perfectly!
    Based on these, I think that the problem is caused by the fact that for some reason VisualGDB specifies the drive letter in lowercase letters in the toolchain root path.

    How can I eliminate this problem?
    Thank you in advance for your help!

    • This topic was modified 4 months, 4 weeks ago by ptihanyi.
    • This topic was modified 4 months, 4 weeks ago by ptihanyi.
    #35854
    support
    Keymaster

    Hi,

    No problem, we can try to help you. Please let us know the email address associated with your license, so that we could link it to your support profile.

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.