crosstools-ng can't find pthread.so

前端 未结 3 956
醉话见心
醉话见心 2021-02-09 08:40

I am trying to use crosstools-ng to compile a program that uses pthread, however for some reason the linker can\'t find the library. I have checked and the libraries are located

3条回答
  •  Happy的楠姐
    2021-02-09 09:15

    Using the GCC --sysroot=dir flag should fix the issue. This flag tells GCC to search both headers and libraries under the dir folder.

    In your case, if you add --sysroot=/home/user/rpi_root to linker flags, ld will search for /home/user/rpi_root/lib/libpthread.so.0 instead of just /lib/libpthread.so.0.

    This is particularly helpful to fix linking with fullpath to library.

    When using CMake to generate build system, you should use SET(CMAKE_SYSROOT ${RPI_ROOT_PATH}), where RPI_ROOT_PATH contains the path to the RPi sysroot instead of directly set compiler flags.

提交回复
热议问题