交叉编译问题记录

交叉编译问题记录

一、关于 –sysroot 的设置问题

从官方解释来看:

1
2
3
4
5
6
--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.

他会对编译和链接过程中,查找头文件和链接库造成影响。

原本会从 /usr/include 目录中搜索头文件、从 /usr/lib 中搜索依赖库。当设置了 --sysroot=dir 后,则从 /dir/usr/include 搜索头文件、从 dir/usr/lib 中搜索依赖库。