crosstools-ng can't find pthread.so

前端 未结 3 1150
隐瞒了意图╮
隐瞒了意图╮ 2021-02-09 08:51

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条回答
  •  说谎
    说谎 (楼主)
    2021-02-09 09:03

    See this info page: https://sourceware.org/binutils/docs-2.24/ld/File-Commands.html#File-Commands

    Read the definitions of INPUT and GROUP, specifically:

    In case a sysroot prefix is configured, and the filename starts with the `/' character, and the script being processed was located inside the sysroot prefix, the filename will be looked for in the sysroot prefix. Otherwise, the linker will try to open the file in the current directory. If it is not found, the linker will search through the archive library search path. See the description of `-L' in Command Line Options.

    So your linker script should be:

    /* GNU ld script
    Use the shared library, but some functions are only in
    the static library, so try that secondarily.  */
    OUTPUT_FORMAT(elf32-littlearm)
    GROUP ( /lib/libpthread.so.0 /usr/lib/libpthread_nonshared.a )
    

    ...as your toolchain is using a sysroot prefix.

    You can find your sysroot prefix with:

    -gcc -print-sysroot
    

提交回复
热议问题