c++ - CMake cross compile -
i'm having problem cmake cross compiler project.
my cross compiler did not find used libraries. setup cross compiler tutorial cross compiler.
now need libs installed on raspberrypi. have snychronised /lib , /usr direcotry pi computer in /opt/cross/rasp. toolchain file:
# 1 important set(cmake_system_name linux) #this 1 not set(cmake_system_version 1) # specify cross compiler set(cmake_c_compiler /opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-gcc) set(cmake_cxx_compiler /opt/cross/x-tools/arm-unknown-linux-gnueabi/bin/arm-unknown-linux-gnueabi-g++) # target environment set(cmake_find_root_path /opt/cross/rasp) # search programs in build host directories set(cmake_find_root_path_mode_program never) # libraries , headers in target directories set(cmake_find_root_path_mode_library only) set(cmake_find_root_path_mode_include only)
but when try compile program following linking error:
/opt/cross/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.9.1/../../../../arm-unknown-linux-gnueabi/bin/ld: warning: libltdl.so.7, needed /opt/cross/rasp/usr/local/lib/libgphoto2.so, not found (try using -rpath or -rpath-link) /opt/cross/x-tools/arm-unknown-linux-gnueabi/lib/gcc/arm-unknown-linux-gnueabi/4.9.1/../../../../arm-unknown-linux-gnueabi/bin/ld: warning: libexif.so.12, needed /opt/cross/rasp/usr/local/lib/libgphoto2.so, not found (try using -rpath or -rpath-link)
on raspberrpi compiling without errors possible.
the problem seems link misinterpretation of etc/ld.so.conf see fixing-rpath-link-issues-with-cross-compilers
in order add missing rpath-link, can append toolchain cmake file :
set(cmake_exe_linker_flags "-wl,-rpath-link=/opt/cross/rasp/lib/arm-linux-gnueabihf:/opt/cross/rasp/usr/lib/arm-linux-gnueabihf")
Comments
Post a Comment