當前位置:編程學習大全網 - 源碼下載 - gcc交叉編譯怎麽找頭文件及lib庫的

gcc交叉編譯怎麽找頭文件及lib庫的

是在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 produce a specs file via the following command.

gcc -dumpspecs > 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

  • 上一篇:中原2022源代碼
  • 下一篇:源代碼紅杉婺源
  • copyright 2024編程學習大全網