gcc交叉编译怎么找头文件及lib库的
发布网友
发布时间:2022-04-21 10:32
我来回答
共1个回答
热心网友
时间:2022-04-15 06:20
是在specs里面读取的路径信息。
命令行中键入 gcc -v
Reading specs from /usr/lib/gcc/i686-pc-cygwin/3.4.4/specs
Configured with: /usr/build/package/orig/test.respin/gcc-3.4.4-3/configure --ver
bose --prefix=/usr --exec-prefix=/usr --sysconfdir=/etc --libdir=/usr/lib --libe
xecdir=/usr/lib --mandir=/usr/share/man --infodir=/usr/share/info --enable-langu
ages=c,ada,c++,d,f77,pascal,java,objc --enable-nls --without-included-gettext --
enable-version-specific-runtime-libs --without-x --enable-libgcj --disable-java-
awt --with-system-zlib --enable-interpreter --disable-libgcj-debug --enable-thre
ads=posix --enable-java-gc=boehm --disable-win32-registry --enable-sjlj-exceptio
ns --enable-hash-synchronization --enable-libstdcxx-debug
Thread model: posix
gcc version 3.4.4 (cygming special, gdc 0.12, using dmd 0.125)
注意“--prefix=/usr” 以及“--libdir=/usr/lib ”
表示gcc ld as 等可执行文件安装在/usr/bin,而libc.a 等文件是在/usr/lib中。
解压缩交叉编译器时,也是要解压缩在在--prefix 指定的目录下。
比如 下载了arm-linux 的交叉编译器cross-3.3.2.tar.bz2,解压缩之后,运行 arm-linux-gcc -v
得到 --prefix=/usr/local/arm。那么就要把 bin lib 等所有的文件和文件夹copy到/usr/local/arm目录下。
否则到时候运行arm-linux-gcc hello.c会提示找不到stdio.h 或者 lib.so.6 等
HOWTO Use the GCC specs file
About Specs file
The "gcc" program invoked by users is a convenient front-end driver executable which will invoke other programs in the background such as cc1, as or ld to do its work according to the command line parameter given. A specs file is plain text used to control the default behavior for the "gcc" front-end. The specs file is usually built-in but for flexibility purposes, it can be overridden with an external version.
Basic Specs file modifications
CC will proce a specs file via the following command.
gcc -mpspecs > specs
You may use a text editor of your choice to inspect it. It may be confusing at first, but there are many places of interest. To use the specs file, invoke gcc with -specs= or place it at "/mingw/lib/gcc/mingw32//specs" to make GCC use it by default, where refers to the GCC version installed.
Adding include directories to the search path
& #160;he *cpp: section should be modified. It contains the following by default:
*cpp:
%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT}
If "z:\libx\include" needs to be added to the GCC includes search path, it should be changed to the following
*cpp:
%{posix:-D_POSIX_SOURCE} %{mthreads:-D_MT} -I/z/libx/include
Adding lib directories to the search path
& #160;he *link_libgcc: section should be modified. It contains the following by default:
*link_libgcc:
%D
& #160;f "z:\libx\lib" needs to be added to the GCC library search path, it should be changed to the following
*link_libgcc:
%D -L/z/libx/lib