<div dir="ltr"><pre style class=""><code><span class="">I am building my project on x86_64 system and want to be able to target it for:<br></span></code></pre><pre style class=""><code><span class="">1. Local platform (x86_64/Linux); and<br>
</span></code></pre><pre style class=""><code><span class="">2. Remote platform (ARM/Raspberry Pi)</span></code><br><code><span class=""></span></code><br></pre><pre style class=""><code><span class=""></span></code>The problem I am encountering is that when I attempt to cross-build for Raspberry Pi, then linker complains about missing symbols (make VERBOSE=1 output):<br>
</pre><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">/opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++       CMakeFiles/Watson.dir/main.cpp.o  -o Watson  -L/opt/rpi-rootfs/usr/lib -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 
-Wl,-rpath,/opt/rpi-rootfs/usr/lib <br>/opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/../lib/gcc/arm-linux-gnueabihf/4.7.2/../../../../arm-linux-gnueabihf/bin/ld: warning: libz.so.1, needed by /opt/rpi-rootfs/usr/lib/libopencv_core.so, not found (try using -rpath or -rpath-link) </blockquote>
<blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><div>... <br></div></blockquote><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
/opt/rpi-rootfs/usr/lib/libopencv_highgui.so: undefined reference to `TIFFSetWarningHandler@LIBTIFF_3.9&#39;<br>/opt/rpi-rootfs/usr/lib/libopencv_highgui.so: undefined reference to `png_read_info@PNG12_0&#39;<br>/opt/rpi-rootfs/usr/lib/libopencv_highgui.so: undefined reference to `g_time_val_add&#39;<br>
...<br></blockquote><pre style class=""></pre><code><span class=""></span></code><pre style class=""><code>My project depends on OpenCV; and OpenCV depends on libz/libtiff; and libz/libtiff are in different directories than all opencv libs that I am using:<br>
</code></pre><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><code><span class="">/opt/rpi-rootfs/usr/lib/libopencv_core.so</span></code><br><code><span class="">/opt/rpi-rootfs/usr/lib/arm-linux-gnueabihf/libtiff.so</span></code><br>
<code><span class=""></span></code></blockquote><pre style class=""><code><span class=""></span></code></pre><pre style class=""><code><span class="">What would be the recommended approach to make linker happy? Maybe there is a cmake command </span></code><code><span class="">that could traverse dependencies and add them? Another solution that seemed to work was to add </span></code>--sysroot /opt/rpi-rootfs to the linker arguments. Can I cmake to do that for me?</pre>
<pre style class=""><code><span class=""><br>This is how my CMakeLists.txt file looks like:<br></span></code></pre><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<code><span class="">cmake_minimum_required(VERSION 2.8)</span></code><br><code><span class=""></span></code><br><code><span class="">project(watson)</span></code><br><code><span class="">find_package(OpenCV REQUIRED)</span></code><br>
<code><span class="">add_executable(Watson main.cpp)</span></code><br><code><span class="">target_link_libraries(Watson ${OpenCV_LIBS})</span></code><br><code><span class=""></span></code></blockquote><pre style class="">
<code><span class=""></span></code></pre><pre style class=""><code><span class="">This is how my CMAKE_TOOLCHAIN_FILE for Raspberry Pi looks like:<br></span></code></pre><blockquote style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<code><span class="">SET(CMAKE_SYSTEM_NAME Linux)</span></code><br><code><span class="">SET(CMAKE_SYSTEM_VERSION 1)</span></code><br><code><span class=""></span></code><br><code><span class="">SET(CMAKE_C_COMPILER /opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-gcc)</span></code><br>
<code><span class="">SET(CMAKE_CXX_COMPILER /opt/tools/arm-bcm2708/gcc-linaro-arm-linux-gnueabihf-raspbian/bin/arm-linux-gnueabihf-g++)</span></code><br><code><span class=""></span></code><br><code><span class="">SET(CMAKE_FIND_ROOT_PATH /opt/rpi-rootfs/)</span></code><br>
<code><span class="">SET(CMAKE_FIND_ROOT_PATH_MODE_PROGRAM NEVER)</span></code><br><code><span class="">SET(CMAKE_FIND_ROOT_PATH_MODE_LIBRARY ONLY)</span></code><br><code><span class="">SET(CMAKE_FIND_ROOT_PATH_MODE_INCLUDE ONLY)</span></code><br>
<code><span class=""></span></code></blockquote><pre style class=""><code><span class="">/lib and /usr directories from Raspberry Pi are rsync&#39;ed to /opt/rpi-rootfs on my x86_64 system.<br><br></span></code></pre><pre style class="">
<code><span class="">Best regards,<br>Ansis<br></span></code></pre></div>