Note that there are some explanatory texts on larger screens.

plurals
  1. POHow to cross compile Raspberry Pi project on x86_64? (missing *.so due to invalid path)
    primarykey
    data
    text
    <p>I am cross compiling Raspberry Pi project on x86_64/Ubuntu 13.04. After invoking <strong>cmake</strong> with:</p> <pre><code>cmake -DCMAKE_TOOLCHAIN_FILE=./Toolchain-raspberry.pi . </code></pre> <p>and then <strong>make</strong>, linking fails:</p> <pre><code>/opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: cannot find -lopencv_gpu ... </code></pre> <p>The problem is that <strong>cmake</strong> generated Makefile invokes linker in the following way:</p> <pre><code>/opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++ CMakeFiles/Watson.dir/main.cpp.o -o Watson -rdynamic -lopencv_gpu -lopencv_contrib -lopencv_legacy -lopencv_objdetect -lopencv_calib3d -lopencv_features2d -lopencv_video -lopencv_highgui -lopencv_ml -lopencv_imgproc -lopencv_flann -lopencv_core </code></pre> <p>and it does not specify paths to those shared libraries. However, if I manually add <strong>--sysroot /opt/rpi-rootfs/</strong> flag to the command above, then linking succeeds.</p> <p><strong>What is the recommended way to get cmake to specify the right paths to the shared libraries when cross compiling?</strong></p> <p>Here is my <strong>Toolchain-raspberry.pi</strong> file:</p> <pre><code>SET(CMAKE_SYSTEM_NAME Linux) SET(CMAKE_SYSTEM_VERSION 1) SET(CMAKE_C_COMPILER /opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc) SET(CMAKE_CXX_COMPILER /opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++) SET(CMAKE_FIND_ROOT_PATH "/opt/rpi-rootfs/") SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER) SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY) SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY) </code></pre> <p>And this is my <strong>CMakeList.txt</strong> file:</p> <pre><code>cmake_minimum_required(VERSION 2.8) project(watson) add_executable(Watson main.cpp) find_package(OpenCV REQUIRED) target_link_libraries(Watson ${OpenCV_LIBS}) </code></pre> <p>The /usr and /lib directories from the target are rsync'ed to /opt/rpi-rootfs/ and all the necessary *.so files are there. After reading <strong>cmake</strong> documentation, I would have expected that setting <strong>CMAKE_FIND_ROOT_PATH</strong> would solve this problem, but apparently not. I am using <strong>cmake</strong> version 2.8.10.1.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload