原文链接:http://www.crifan.com/summary_cross_compile_library_note/
交叉编译库时所最常用到的配置
一般编译都是:
./configure xxx
make
make install
此处,对于./configure的xxx,我最常用的是:
|
1
|
.
/configure
--prefix=YOUR_INSTALL_PATH --build=CURRENT_ENV --target=CROSS_COMPILER --host=CROSS_COMPILER CC=CROSS_COMPILER-gcc OTHER_PARAMETER
|
其中:
–prefix=YOUR_INSTALL_PATH
即,你所要把当前的库,在编译完毕之后,安装到哪里
如:
|
1
|
.
/configure
--prefix=
/opt/crosscompile/xmlrpc
--build=i686-pc-linux-gnu --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi CC=arm-xscale-linux-gnueabi-gcc
|
–build=CURRENT_ENV
目前我遇到的有两种:
- 一个是cygwin:
- –build=i686-pc-cygwin
- 如:
1
./configure--prefix=$HOME/develop/crosstool-ng/x-tools/armxscaleexpat--build=i686-pc-cygwin --target=arm-xscale-linux --host=arm-xscale-linux CC=arm-xscale-linux-gnueabi-gcc
- 如:
- –build=i686-pc-cygwin
- 一个是普通的Linux,比如Ubuntu:
- –build=i686-pc-linux-gnu
- 如
1
./configure--prefix=/opt/crosscompile/curl--build=i686-pc-linux-gnu --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi CC=arm-xscale-linux-gnueabi-gcc --enable-static
- 如
- –build=i686-pc-linux-gnu
关于其值的来历:
(1)其中,此build的值,我之前是参考:
之前编译时的输出:
|
1
2
3
4
5
|
[EXTRA] Dumping internal crosstool-NG configuration
[EXTRA] Building a toolchain
for
:
[EXTRA] build = i686-pc-cygwin
[EXTRA] host = i686-pc-cygwin
[EXTRA] target = arm-xscale-linux-gnueabi
|
而知道的。
(2)其中,此处的build的值,也是参考:
|
1
2
3
4
5
|
[EXTRA] Dumping internal crosstool-NG configuration
[EXTRA] Building a toolchain
for
:
[EXTRA] build = i686-pc-linux-gnu
[EXTRA] host = i686-pc-linux-gnu
[EXTRA] target = arm-xscale-linux-gnueabi
|
才知道的。
–target=CROSS_COMPILER和–host=CROSS_COMPILER
对于target和host,此处,都是设置的是交叉编译器的(前缀)。
比如,如果你的交叉编译器是arm-linux,那就是:
|
1
|
--target=arm-linux --host=arm-linux
|
我此处,用crosstool-ng编译出来的for xscale的交叉编译器是:arm-xscale-linux-gnueabi
所以,此处后续编译各种库,都是用的是:
|
1
|
--target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi
|
举例:
|
1
|
.
/configure
--prefix=$HOME
/develop/crosstool-ng/x-tools/armxscalelog4c
--build=i686-pc-cygwin --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi --with-expat-prefix=$HOME
/develop/crosstool-ng/x-tools/armxscaleexpat
CC=arm-xscale-linux-gnueabi-gcc
|
如:
|
1
|
.
/configure
--prefix=
/opt/crosscompile/curl
--build=i686-pc-linux-gnu --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi CC=arm-xscale-linux-gnueabi-gcc --
enable
-static
|
CC=CROSS_COMPILER-gcc
1.此处的CC参数,是用于指定编译器用哪个。
一般都是对应的交叉编译器的前缀,加上gcc,比如:
arm-linux的话,加上gcc就是:arm-linux-gcc
arm-xscale-linux-gnueabi加上gcc,就是:arm-xscale-linux-gnueabi-gcc
2.而且,也多数都是可以在./configure时,就设置好对应的CC的值的。
如:
|
1
|
.
/configure
--prefix=
/opt/crosscompile/curl
--build=i686-pc-linux-gnu --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi CC=arm-xscale-linux-gnueabi-gcc --
enable
-static
|
之后,直接去make即可。
但是也有例外:
有时,由于configure不支持设置CC,所以需要放到后面的make才行,即:
|
1
2
|
.
/configure
--prefix=$HOME
/develop/crosstool-ng/x-tools/libcgi
--build=i686-pc-cygwin --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi
make
CC=arm-xscale-linux-gnueabi-gcc
|
OTHER_PARAMETER
1../configure可以去添加你所需要的参数
但是一般都支持的规则是:
–enable-xxx:启用(编译)某个子模块或功能(feature)
–disable-xxx:禁止(不编译)某个子模块或功能(feature)
–with-xxx:类似于–enable-xxx
–without-xxx:类似于–disable-xxx
经过调试错误,发现就不需要编译python,所以,可以去添加对应的
--without-python
去禁止编译python。
所用的配置就是:
|
1
|
.
/configure
--prefix=
/opt/crosscompile/libxml2
--build=i686-pc-linux-gnu --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi CC=arm-xscale-linux-gnueabi-gcc --without-python
|
2.添加参数之前,需要搞清楚,当前你所要去编译的库,本身支持什么参数。
正常都是可以通过:
|
1
|
.
/configure
--help
|
去查看到,当前模块,所支持哪些参数。
`configure' configures this package to adapt to many kinds of systems.
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g., CC, CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
Configuration:
-h, --help display this help and exit
--help=short display options specific to this package
--help=recursive display the short help of all the included packages
-V, --version display version information and exit
-q, --quiet, --silent do not print `checking ...' messages
--cache-file=FILE cache test results in FILE [disabled]
-C, --config-cache alias for `--cache-file=config.cache'
-n, --no-create do not create output files
--srcdir=DIR find the sources in DIR [configure dir or `..']
Installation directories:
--prefix=PREFIX install architecture-independent files in PREFIX
[/usr/local]
--exec-prefix=EPREFIX install architecture-dependent files in EPREFIX
[PREFIX]
By default, `make install' will install all the files in
`/usr/local/bin', `/usr/local/lib' etc. You can specify
an installation prefix other than `/usr/local' using `--prefix',
for instance `--prefix=$HOME'.
For better control, use the options below.
Fine tuning of the installation directories:
--bindir=DIR user executables [EPREFIX/bin]
--sbindir=DIR system admin executables [EPREFIX/sbin]
--libexecdir=DIR program executables [EPREFIX/libexec]
--sysconfdir=DIR read-only single-machine data [PREFIX/etc]
--sharedstatedir=DIR modifiable architecture-independent data [PREFIX/com]
--localstatedir=DIR modifiable single-machine data [PREFIX/var]
--libdir=DIR object code libraries [EPREFIX/lib]
--includedir=DIR C header files [PREFIX/include]
--oldincludedir=DIR C header files for non-gcc [/usr/include]
--datarootdir=DIR read-only arch.-independent data root [PREFIX/share]
--datadir=DIR read-only architecture-independent data [DATAROOTDIR]
--infodir=DIR info documentation [DATAROOTDIR/info]
--localedir=DIR locale-dependent data [DATAROOTDIR/locale]
--mandir=DIR man documentation [DATAROOTDIR/man]
--docdir=DIR documentation root [DATAROOTDIR/doc/PACKAGE]
--htmldir=DIR html documentation [DOCDIR]
--dvidir=DIR dvi documentation [DOCDIR]
--pdfdir=DIR pdf documentation [DOCDIR]
--psdir=DIR ps documentation [DOCDIR]
Program names:
--program-prefix=PREFIX prepend PREFIX to installed program names
--program-suffix=SUFFIX append SUFFIX to installed program names
--program-transform-name=PROGRAM run sed PROGRAM on installed program names
System types:
--build=BUILD configure for building on BUILD [guessed]
--host=HOST cross-compile to build programs to run on HOST [BUILD]
Optional Features:
--disable-option-checking ignore unrecognized --enable/--with options
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-silent-rules less verbose build output (undo: `make V=1')
--disable-silent-rules verbose build output (undo: `make V=0')
--disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors
--enable-shared[=PKGS] build shared libraries [default=yes]
--enable-static[=PKGS] build static libraries [default=yes]
--enable-fast-install[=PKGS]
optimize for fast installation [default=yes]
--disable-libtool-lock avoid locking (might break parallel builds)
--enable-rebuild-docs[=yes/no] rebuild some generated docs [default=no]
--enable-ipv6[=yes/no] enables compilation of IPv6 code [default=yes]
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
both]
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot=DIR Search for dependent libraries within DIR
(or the compiler's sysroot if not specified).
--with-c14n add the Canonicalization support (on)
--with-catalog add the Catalog support (on)
--with-debug add the debugging module (on)
--with-docbook add Docbook SGML support (on)
--with-fexceptions add GCC flag -fexceptions for C++ exceptions (off)
--with-ftp add the FTP support (on)
--with-history add history support to xmllint shell(off)
--with-html add the HTML support (on)
--with-html-dir=path path to base html directory, default
$datadir/doc/html
--with-html-subdir=path directory used under html-dir, default
$PACKAGE-$VERSION/html
--with-http add the HTTP support (on)
--with-iconv[=DIR] add ICONV support (on)
--with-icu add ICU support (off)
--with-iso8859x add ISO8859X support if no iconv (on)
--with-legacy add deprecated APIs for compatibility (on)
--with-mem-debug add the memory debugging module (off)
--with-minimum build a minimally sized library (off)
--with-output add the serialization support (on)
--with-pattern add the xmlPattern selection interface (on)
--with-push add the PUSH parser interfaces (on)
--with-python[=DIR] build Python bindings if found
--with-reader add the xmlReader parsing interface (on)
--with-readline=DIR use readline in DIR
--with-regexps add Regular Expressions support (on)
--with-run-debug add the runtime debugging module (off)
--with-sax1 add the older SAX1 interface (on)
--with-schemas add Relax-NG and Schemas support (on)
--with-schematron add Schematron support (on)
--with-threads add multithread support(on)
--with-thread-alloc add per-thread memory(off)
--with-tree add the DOM like tree manipulation APIs (on)
--with-valid add the DTD validation support (on)
--with-writer add the xmlWriter saving interface (on)
--with-xinclude add the XInclude support (on)
--with-xpath add the XPATH support (on)
--with-xptr add the XPointer support (on)
--with-modules add the dynamic modules support (on)
--with-zlib[=DIR] use libz in DIR
--with-lzma[=DIR] use liblzma in DIR
--with-coverage build for code coverage with GCC (off)
Some influential environment variables:
CC C compiler command
CFLAGS C compiler flags
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
LIBS libraries to pass to the linker, e.g. -l<library>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CPP C preprocessor
Use these variables to override the choices made by `configure' or to help
it to find libraries and programs with nonstandard names/locations.
Report bugs to the package provider.
交叉编译库配置详解
372

被折叠的 条评论
为什么被折叠?



