最新消息:20210816 当前crifan.com域名已被污染,为防止失联,请关注(页面右下角的)公众号

【记录】Ubuntu下用arm-xscale-linux-gnueabi交叉编译expat

CrossCompiler crifan 3179浏览 0评论

【背景】

折腾完:

【记录】Ubuntu下用arm-xscale-linux-gnueabi交叉编译xmlrpc

【记录】Ubuntu下用arm-xscale-linux-gnueabi交叉编译curl(libcurl)

【记录】Ubuntu下用arm-xscale-linux-gnueabi交叉编译libxml2

需要在交叉编译log4c之前,去折腾交叉编译expat。

【折腾过程】

1.继续参考之前自己的:

【记录】Cygwin下用arm-xscale-linux-gnueabi交叉编译expat

2.先拿到源码:

crifan@ubuntu:expat-2.1.0$ ll -h
total 980K
drwxrwxr-x 13 crifan crifan 4.0K Mar 24  2012 ./
drwxrwxr-x  3 crifan crifan 4.0K Aug  9 00:19 ../
-rw-rw-r--  1 crifan crifan 298K Mar 24  2012 aclocal.m4
drwxrwxr-x  3 crifan crifan 4.0K Mar 24  2012 amiga/
drwxrwxr-x  2 crifan crifan 4.0K Mar 24  2012 bcb5/
-rw-rw-r--  1 crifan crifan  12K Mar 24  2012 Changes
-rwxrwxr-x  1 crifan crifan 3.3K Mar  5  2012 CMakeLists.txt*
-rwxrwxr-x  1 crifan crifan 1.8K Mar  5  2012 CMake.README*
-rwxrwxr-x  1 crifan crifan 553K Mar 24  2012 configure*
-rwxrwxr-x  1 crifan crifan 1.5K Mar  5  2012 ConfigureChecks.cmake*
-rw-rw-r--  1 crifan crifan 4.6K Mar  3  2012 configure.in
drwxrwxr-x  2 crifan crifan 4.0K Mar 24  2012 conftools/
-rw-rw-r--  1 crifan crifan 1.2K Dec 28  2005 COPYING
drwxrwxr-x  2 crifan crifan 4.0K Mar 24  2012 doc/
drwxrwxr-x  2 crifan crifan 4.0K Mar 24  2012 examples/
-rwxrwxr-x  1 crifan crifan 2.7K Mar  5  2012 expat_config.h.cmake*
-rw-rw-r--  1 crifan crifan 2.7K Mar 24  2012 expat_config.h.in
-rwxrwxr-x  1 crifan crifan 2.0K Sep 29  2004 expat.dsw*
-rw-rw-r--  1 crifan crifan  231 Jan 18  2009 expat.pc.in
drwxrwxr-x  2 crifan crifan 4.0K Mar 24  2012 lib/
drwxrwxr-x  2 crifan crifan 4.0K Mar 24  2012 m4/
-rw-rw-r--  1 crifan crifan 6.9K Mar 18  2012 Makefile.in
-rw-rw-r--  1 crifan crifan 2.5K Mar  5  2012 MANIFEST
-rw-rw-r--  1 crifan crifan 5.7K Mar 10  2012 README
drwxrwxr-x  3 crifan crifan 4.0K Mar 24  2012 tests/
drwxrwxr-x  2 crifan crifan 4.0K Mar 24  2012 vms/
drwxrwxr-x  2 crifan crifan 4.0K Mar 24  2012 win32/
drwxrwxr-x  2 crifan crifan 4.0K Mar 24  2012 xmlwf/
crifan@ubuntu:expat-2.1.0$ pwd
/home/crifan/develop/crosscompile/expat/expat-2.1.0
crifan@ubuntu:expat-2.1.0$ 

3.去配置:

crifan@ubuntu:expat-2.1.0$ ./configure --prefix=/opt/crosscompile/expat --build=i686-pc-linux-gnu --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi CC=arm-xscale-linux-gnueabi-gcc
checking build system type... i686-pc-linux-gnu
checking host system type... arm-xscale-linux-gnueabi
checking how to print strings... printf
checking for arm-xscale-linux-gnueabi-gcc... arm-xscale-linux-gnueabi-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables... 
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether arm-xscale-linux-gnueabi-gcc accepts -g... yes
checking for arm-xscale-linux-gnueabi-gcc option to accept ISO C89... none needed
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by arm-xscale-linux-gnueabi-gcc... /opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/bin/ld
checking if the linker (/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin/arm-xscale-linux-gnueabi-nm -B
checking the name lister (/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin/arm-xscale-linux-gnueabi-nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking whether the shell understands some XSI constructs... yes
checking whether the shell understands "+="... yes
checking how to convert i686-pc-linux-gnu file names to arm-xscale-linux-gnueabi format... func_convert_file_noop
checking how to convert i686-pc-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/bin/ld option to reload object files... -r
checking for arm-xscale-linux-gnueabi-objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for arm-xscale-linux-gnueabi-dlltool... dlltool
checking how to associate runtime and link libraries... printf %s\n
checking for arm-xscale-linux-gnueabi-ar... arm-xscale-linux-gnueabi-ar
checking for archiver @FILE support... @
checking for arm-xscale-linux-gnueabi-strip... arm-xscale-linux-gnueabi-strip
checking for arm-xscale-linux-gnueabi-ranlib... arm-xscale-linux-gnueabi-ranlib
checking for gawk... gawk
checking command to parse /opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin/arm-xscale-linux-gnueabi-nm -B output from arm-xscale-linux-gnueabi-gcc object... ok
checking for sysroot... no
checking for arm-xscale-linux-gnueabi-mt... no
checking for mt... mt
configure: WARNING: using cross tools not prefixed with host triplet
checking if mt is a manifest tool... no
checking how to run the C preprocessor... arm-xscale-linux-gnueabi-gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if arm-xscale-linux-gnueabi-gcc supports -fno-rtti -fno-exceptions... no
checking for arm-xscale-linux-gnueabi-gcc option to produce PIC... -fPIC -DPIC
checking if arm-xscale-linux-gnueabi-gcc PIC flag -fPIC -DPIC works... yes
checking if arm-xscale-linux-gnueabi-gcc static flag -static works... yes
checking if arm-xscale-linux-gnueabi-gcc supports -c -o file.o... yes
checking if arm-xscale-linux-gnueabi-gcc supports -c -o file.o... (cached) yes
checking whether the arm-xscale-linux-gnueabi-gcc linker (/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for arm-xscale-linux-gnueabi-gcc... (cached) arm-xscale-linux-gnueabi-gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether arm-xscale-linux-gnueabi-gcc accepts -g... (cached) yes
checking for arm-xscale-linux-gnueabi-gcc option to accept ISO C89... (cached) none needed
checking for arm-xscale-linux-gnueabi-g++... arm-xscale-linux-gnueabi-g++
checking whether we are using the GNU C++ compiler... yes
checking whether arm-xscale-linux-gnueabi-g++ accepts -g... yes
checking how to run the C++ preprocessor... arm-xscale-linux-gnueabi-g++ -E
checking for ld used by arm-xscale-linux-gnueabi-g++... /opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/bin/ld
checking if the linker (/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/bin/ld) is GNU ld... yes
checking whether the arm-xscale-linux-gnueabi-g++ linker (/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/bin/ld) supports shared libraries... yes
checking for arm-xscale-linux-gnueabi-g++ option to produce PIC... -fPIC -DPIC
checking if arm-xscale-linux-gnueabi-g++ PIC flag -fPIC -DPIC works... yes
checking if arm-xscale-linux-gnueabi-g++ static flag -static works... yes
checking if arm-xscale-linux-gnueabi-g++ supports -c -o file.o... yes
checking if arm-xscale-linux-gnueabi-g++ supports -c -o file.o... (cached) yes
checking whether the arm-xscale-linux-gnueabi-g++ linker (/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/arm-xscale-linux-gnueabi/bin/ld) supports shared libraries... yes
checking dynamic linker characteristics... (cached) GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking for a BSD-compatible install... /usr/bin/install -c
checking whether arm-xscale-linux-gnueabi-gcc accepts -fexceptions... yes
checking for ANSI C header files... (cached) yes
checking whether byte ordering is bigendian... no
checking for an ANSI C-conforming const... yes
checking for size_t... yes
checking for memmove... yes
checking for bcopy... yes
checking fcntl.h usability... yes
checking fcntl.h presence... yes
checking for fcntl.h... yes
checking for unistd.h... (cached) yes
checking for off_t... yes
checking for stdlib.h... (cached) yes
checking for unistd.h... (cached) yes
checking for sys/param.h... yes
checking for getpagesize... yes
checking for working mmap... no
checking for arm-xscale-linux-gnueabi-gcc option to accept ISO C99... -std=gnu99
checking for arm-xscale-linux-gnueabi-gcc -std=gnu99 option to accept ISO Standard C... (cached) -std=gnu99
checking for an ANSI C99-conforming __func__... yes
configure: creating ./config.status
config.status: creating Makefile
config.status: WARNING:  'Makefile.in' seems to ignore the --datarootdir setting
config.status: creating expat.pc
config.status: creating expat_config.h
config.status: executing libtool commands
crifan@ubuntu:expat-2.1.0$ 

4.再去编译:

crifan@ubuntu:expat-2.1.0$ make
/bin/bash ./libtool --silent --mode=compile arm-xscale-linux-gnueabi-gcc -std=gnu99 -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions  -DHAVE_EXPAT_CONFIG_H -o lib/xmlparse.lo -c lib/xmlparse.c
/bin/bash ./libtool --silent --mode=compile arm-xscale-linux-gnueabi-gcc -std=gnu99 -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions  -DHAVE_EXPAT_CONFIG_H -o lib/xmltok.lo -c lib/xmltok.c
/bin/bash ./libtool --silent --mode=compile arm-xscale-linux-gnueabi-gcc -std=gnu99 -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions  -DHAVE_EXPAT_CONFIG_H -o lib/xmlrole.lo -c lib/xmlrole.c
/bin/bash ./libtool --silent --mode=link arm-xscale-linux-gnueabi-gcc -std=gnu99 -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions  -DHAVE_EXPAT_CONFIG_H -no-undefined -version-info 7:0:6 -rpath /opt/crosscompile/expat/lib  -o libexpat.la lib/xmlparse.lo lib/xmltok.lo lib/xmlrole.lo
arm-xscale-linux-gnueabi-gcc -std=gnu99 -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions  -DHAVE_EXPAT_CONFIG_H -o xmlwf/xmlwf.o -c xmlwf/xmlwf.c
arm-xscale-linux-gnueabi-gcc -std=gnu99 -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions  -DHAVE_EXPAT_CONFIG_H -o xmlwf/xmlfile.o -c xmlwf/xmlfile.c
arm-xscale-linux-gnueabi-gcc -std=gnu99 -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions  -DHAVE_EXPAT_CONFIG_H -o xmlwf/codepage.o -c xmlwf/codepage.c
arm-xscale-linux-gnueabi-gcc -std=gnu99 -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions  -DHAVE_EXPAT_CONFIG_H -o xmlwf/readfilemap.o -c xmlwf/readfilemap.c
xmlwf/readfilemap.c: In function 'filemap':
xmlwf/readfilemap.c:61:5: warning: implicit declaration of function 'close' [-Wimplicit-function-declaration]
xmlwf/readfilemap.c:83:3: warning: implicit declaration of function 'read' [-Wimplicit-function-declaration]
/bin/bash ./libtool --silent --mode=link arm-xscale-linux-gnueabi-gcc -std=gnu99 -I./lib -I. -g -O2 -Wall -Wmissing-prototypes -Wstrict-prototypes -fexceptions  -DHAVE_EXPAT_CONFIG_H  -o xmlwf/xmlwf xmlwf/xmlwf.o xmlwf/xmlfile.o xmlwf/codepage.o xmlwf/readfilemap.o libexpat.la

5.再去安装:

crifan@ubuntu:expat-2.1.0$ make install
/bin/bash ./conftools/mkinstalldirs /opt/crosscompile/expat/lib /opt/crosscompile/expat/include /opt/crosscompile/expat/lib/pkgconfig
mkdir /opt/crosscompile/expat/lib
mkdir /opt/crosscompile/expat/include
mkdir /opt/crosscompile/expat/lib/pkgconfig
/bin/bash ./libtool --mode=install /usr/bin/install -c libexpat.la /opt/crosscompile/expat/lib/libexpat.la
libtool: install: /usr/bin/install -c .libs/libexpat.so.1.6.0 /opt/crosscompile/expat/lib/libexpat.so.1.6.0
libtool: install: (cd /opt/crosscompile/expat/lib && { ln -s -f libexpat.so.1.6.0 libexpat.so.1 || { rm -f libexpat.so.1 && ln -s libexpat.so.1.6.0 libexpat.so.1; }; })
libtool: install: (cd /opt/crosscompile/expat/lib && { ln -s -f libexpat.so.1.6.0 libexpat.so || { rm -f libexpat.so && ln -s libexpat.so.1.6.0 libexpat.so; }; })
libtool: install: /usr/bin/install -c .libs/libexpat.lai /opt/crosscompile/expat/lib/libexpat.la
libtool: install: /usr/bin/install -c .libs/libexpat.a /opt/crosscompile/expat/lib/libexpat.a
libtool: install: chmod 644 /opt/crosscompile/expat/lib/libexpat.a
libtool: install: arm-xscale-linux-gnueabi-ranlib /opt/crosscompile/expat/lib/libexpat.a
libtool: finish: PATH="/usr/lib/lightdm/lightdm:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin:/usr/games:/usr/local/games:/opt/crosstool-ng/bin:/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin:/opt/crosstool-ng/bin:/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin:/opt/crosstool-ng/bin:/opt/crosscompile/xscale/gcc-4.6.0-glibc-2.9/bin:/sbin" ldconfig -n /opt/crosscompile/expat/lib
----------------------------------------------------------------------
Libraries have been installed in:
   /opt/crosscompile/expat/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,-rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
for FN in ./lib/expat.h ./lib/expat_external.h ; do /usr/bin/install -c -m 644 $FN /opt/crosscompile/expat/include ; done
/usr/bin/install -c -m 644 expat.pc /opt/crosscompile/expat/lib/pkgconfig/expat.pc
/bin/bash ./conftools/mkinstalldirs /opt/crosscompile/expat/bin /opt/crosscompile/expat/share/man/man1
mkdir /opt/crosscompile/expat/bin
mkdir /opt/crosscompile/expat/share
mkdir /opt/crosscompile/expat/share/man
mkdir /opt/crosscompile/expat/share/man/man1
/bin/bash ./libtool --mode=install /usr/bin/install -c xmlwf/xmlwf /opt/crosscompile/expat/bin/xmlwf
libtool: install: /usr/bin/install -c xmlwf/.libs/xmlwf /opt/crosscompile/expat/bin/xmlwf
/usr/bin/install -c -m 644 ./doc/xmlwf.1 /opt/crosscompile/expat/share/man/man1
crifan@ubuntu:expat-2.1.0$ 

6.再去确认:

crifan@ubuntu:expat-2.1.0$ ls /opt/crosscompile/expat/ -lh
total 16K
drwxrwxr-x 2 crifan crifan 4.0K Aug  9 00:21 bin
drwxrwxr-x 2 crifan crifan 4.0K Aug  9 00:21 include
drwxrwxr-x 3 crifan crifan 4.0K Aug  9 00:21 lib
drwxrwxr-x 3 crifan crifan 4.0K Aug  9 00:21 share
crifan@ubuntu:expat-2.1.0$ ls /opt/crosscompile/expat/bin -lh
total 52K
-rwxr-xr-x 1 crifan crifan 52K Aug  9 00:21 xmlwf
crifan@ubuntu:expat-2.1.0$ ls /opt/crosscompile/expat/include/ -lh
total 48K
-rw-r--r-- 1 crifan crifan 3.3K Aug  9 00:21 expat_external.h
-rw-r--r-- 1 crifan crifan  41K Aug  9 00:21 expat.h
crifan@ubuntu:expat-2.1.0$ ls /opt/crosscompile/expat/lib -lh
total 836K
-rw-r--r-- 1 crifan crifan 464K Aug  9 00:21 libexpat.a
-rwxr-xr-x 1 crifan crifan  955 Aug  9 00:21 libexpat.la
lrwxrwxrwx 1 crifan crifan   17 Aug  9 00:21 libexpat.so -> libexpat.so.1.6.0
lrwxrwxrwx 1 crifan crifan   17 Aug  9 00:21 libexpat.so.1 -> libexpat.so.1.6.0
-rwxr-xr-x 1 crifan crifan 362K Aug  9 00:21 libexpat.so.1.6.0
drwxrwxr-x 2 crifan crifan 4.0K Aug  9 00:21 pkgconfig
crifan@ubuntu:expat-2.1.0$ ls /opt/crosscompile/expat/share/man/man1/ -lh
total 8.0K
-rw-r--r-- 1 crifan crifan 7.8K Aug  9 00:21 xmlwf.1
crifan@ubuntu:expat-2.1.0$ 

ok了。

 

【总结】

此处,在Ubuntu下,交叉编译expat很简单:

1.配置:

./configure --prefix=/opt/crosscompile/expat --build=i686-pc-linux-gnu --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi CC=arm-xscale-linux-gnueabi-gcc

2.编译:

make

3.安装:

make install

转载请注明:在路上 » 【记录】Ubuntu下用arm-xscale-linux-gnueabi交叉编译expat

发表我的评论
取消评论

表情

Hi,您需要填写昵称和邮箱!

  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
82 queries in 0.203 seconds, using 22.30MB memory