set global gcc default search paths

前端 未结 2 1449
一个人的身影
一个人的身影 2021-02-02 00:37

when running

arm-none-linux-gnueabi-gcc -print-search-dirs | grep libraries | sed \'s/:/\\n/g\'

I get the following output:

li         


        
2条回答
  •  星月不相逢
    2021-02-02 01:14

    As explained by @osgx, gcc is looking in the wrong path for its libraries. I hit a similar issue when trying to cross-compile a program for arm on x86_64. As editing the root-owned files was not an option, I searched further and discovered the --sysroot option:

    --sysroot=dir
    Use dir as the logical root directory for headers and libraries. For example, if the compiler normally searches for headers in /usr/include and libraries in /usr/lib, it instead searches dir/usr/include and dir/usr/lib.

    If you use both this option and the -isysroot option, then the --sysroot option applies to libraries, but the -isysroot option applies to header files.

    The GNU linker (beginning with version 2.16) has the necessary support for this option. If your linker does not support this option, the header file aspect of --sysroot still works, but the library aspect does not.

    Example usage:

    ./configure --host=arm-unknown-linux-gnueabi \
        CFLAGS='-g -O2 --sysroot=/tmp/rpi-root'
    

提交回复
热议问题