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

【背景】

折腾完:

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

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

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

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

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

再去交叉编译libcgi。

 

【折腾过程】

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

【记录】cygwin下用arm-xscale-linux-gnueabi交叉编译libcgi

2.先拿到全新的源码:

crifan@ubuntu:libcgi-1.0$ pwd
/home/crifan/develop/crosscompile/libcgi/libcgi-1.0
crifan@ubuntu:libcgi-1.0$ ls -lh
total 104K
-rwxrwxrwx 1 crifan root   58 Jan 20  2013 AUTHORS
-rwxrwxrwx 1 crifan root   62 Jan 20  2013 autogen.sh
-rwxrwxrwx 1 crifan root  204 Jan 20  2013 BUGS
-rwxrwxrwx 1 crifan root 5.1K Jan 20  2013 ChangeLog
-rwxrwxrwx 1 crifan root  44K Jan 20  2013 configure
-rwxrwxrwx 1 crifan root  206 Jan 20  2013 configure.in
drwxrwxrwx 4 crifan root 4.0K Aug  9 00:45 doc
drwxrwxrwx 8 crifan root 4.0K Aug  9 00:45 examples
-rwxrwxrwx 1 crifan root 4.7K Jan 20  2013 install-sh
-rwxrwxrwx 1 crifan root 2.4K Jan 20  2013 Makefile.in
-rwxrwxrwx 1 crifan root  613 Jan 20  2013 README
drwxrwxrwx 2 crifan root 4.0K Aug  9 00:45 src
-rwxrwxrwx 1 crifan root  645 Jan 20  2013 THANKS
-rwxrwxrwx 1 crifan root  500 Jan 20  2013 TODO
crifan@ubuntu:libcgi-1.0$ 

3.然后配置之前,去注意不要加CC,用如下配置:

crifan@ubuntu:libcgi-1.0$ mkdir /opt/crosscompile/libcgi
crifan@ubuntu:libcgi-1.0$ ./configure --prefix=/opt/crosscompile/libcgi --build=i686-pc-linux-gnu --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi
creating cache ./config.cache
checking for gcc... gcc
checking whether the C compiler (gcc  ) works... yes
checking whether the C compiler (gcc  ) is a cross-compiler... no
checking whether we are using GNU C... yes
checking whether gcc accepts -g... yes
checking for a BSD compatible install... /usr/bin/install -c
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
updating cache ./config.cache
creating ./config.status
creating Makefile
creating src/config.h
src/config.h is unchanged
crifan@ubuntu:libcgi-1.0$ 

4.然后编译之前,参考:

【已解决】cygwin下用arm-xscale-linux-gnueabi交叉编译libcgi出错:src/string.c:587:2: error: incompatible type for argument 2 of ‘__builtin_va_copy’

去修改文件:

libcgi-1.0\src\string.c

中的587行的,从:

va_copy(bkp, str);

改为:

//va_copy(bkp, str);
va_copy(bkp, ptr);

同时,之前已经对于prefix的目录,新建过了:

crifan@ubuntu:libcgi-1.0$ mkdir /opt/crosscompile/libcgi

所以,不用修改makefile,确保后期make install是OK的。

5.然后再去make,且加CC参数:

crifan@ubuntu:libcgi-1.0$ make CC=arm-xscale-linux-gnueabi-gcc
arm-xscale-linux-gnueabi-gcc    -c -o src/error.o src/error.c
arm-xscale-linux-gnueabi-gcc    -c -o src/cgi.o src/cgi.c
arm-xscale-linux-gnueabi-gcc    -c -o src/session.o src/session.c
arm-xscale-linux-gnueabi-gcc    -c -o src/base64.o src/base64.c
arm-xscale-linux-gnueabi-gcc    -c -o src/md5.o src/md5.c
arm-xscale-linux-gnueabi-gcc    -c -o src/string.o src/string.c
arm-xscale-linux-gnueabi-gcc    -c -o src/general.o src/general.c
arm-xscale-linux-gnueabi-gcc    -c -o src/list.o src/list.c
arm-xscale-linux-gnueabi-gcc    -c -o src/cookie.o src/cookie.c
ar rc src/libcgi.a src/error.o src/cgi.o src/session.o src/base64.o src/md5.o src/string.o src/general.o src/list.o src/cookie.o
arm-xscale-linux-gnueabi-gcc -shared -o src/libcgi.so src/error.o src/cgi.o src/session.o src/base64.o src/md5.o src/string.o src/general.o src/list.o src/cookie.o 



+---------------------------------------+
|       Thanks for using LibCGI         |
+---------------------------------------+
| LibCGI is getting better because      |
| people like you are using it. So, if  |
| LibCGI is helping you in some way,    |
| please help us to improve it, sending |
| suggestions, bug reports, bug fixes,  |
| and specially improvment code.        |
| You can subscribe to the mailing list |
| or send a mail to the author.         |
+---------------------------------------+---------------------------+
| List: http://lists.sourceforge.net/lists/listinfo/libcgi-general  |
+-------------------------------------------------------------------+

crifan@ubuntu:libcgi-1.0$ 

6.然后去安装:

crifan@ubuntu:libcgi-1.0$ make install
cp src/libcgi.a /opt/crosscompile/libcgi/lib
cp src/libcgi.so /opt/crosscompile/libcgi/lib
cp src/cgi.h /opt/crosscompile/libcgi/include
cp src/session.h /opt/crosscompile/libcgi/include

再去确认一把,结果,还是很坑爹,是错的:

crifan@ubuntu:libcgi-1.0$ ls /opt/crosscompile/libcgi/
include  lib
crifan@ubuntu:libcgi-1.0$ ls /opt/crosscompile/libcgi/ -lh
total 48K
-rwxrwxr-x 1 crifan crifan 1.1K Aug  9 00:52 include
-rw-rw-r-- 1 crifan crifan  44K Aug  9 00:52 lib
crifan@ubuntu:libcgi-1.0$ ls /opt/crosscompile/libcgi/include -lh
-rwxrwxr-x 1 crifan crifan 1.1K Aug  9 00:52 /opt/crosscompile/libcgi/include
crifan@ubuntu:libcgi-1.0$ 

7.所以,继续去删除旧的,重新拷贝:

其中修改Makefile为:

install:
	mkdir -p $(LIBDIR)
	cp src/libcgi.a $(LIBDIR)
	cp src/libcgi.so $(LIBDIR)
	mkdir -p $(INCDIR)
	cp src/cgi.h $(INCDIR)
	cp src/session.h $(INCDIR)

 

过程为:

crifan@ubuntu:libcgi-1.0$ rm /opt/crosscompile/libcgi/lib
crifan@ubuntu:libcgi-1.0$ rm /opt/crosscompile/libcgi/include 
crifan@ubuntu:libcgi-1.0$ mkdir /opt/crosscompile/libcgi/inclue
crifan@ubuntu:libcgi-1.0$ mkdir /opt/crosscompile/libcgi/lib
crifan@ubuntu:libcgi-1.0$ make install
cp src/libcgi.a /opt/crosscompile/libcgi/lib
cp src/libcgi.so /opt/crosscompile/libcgi/lib
cp src/cgi.h /opt/crosscompile/libcgi/include
cp src/session.h /opt/crosscompile/libcgi/include
crifan@ubuntu:libcgi-1.0$ ls /opt/crosscompile/libcgi/ -lh
total 12K
-rwxrwxr-x 1 crifan crifan 1.1K Aug  9 00:54 include
drwxrwxr-x 2 crifan crifan 4.0K Aug  9 00:54 inclue
drwxrwxr-x 2 crifan crifan 4.0K Aug  9 00:54 lib
crifan@ubuntu:libcgi-1.0$ rm /opt/crosscompile/libcgi/include
crifan@ubuntu:libcgi-1.0$ ls /opt/crosscompile/libcgi/ -lh
total 8.0K
drwxrwxr-x 2 crifan crifan 4.0K Aug  9 00:54 inclue
drwxrwxr-x 2 crifan crifan 4.0K Aug  9 00:54 lib
crifan@ubuntu:libcgi-1.0$ ls /opt/crosscompile/libcgi/lib/ -lh
total 88K
-rw-rw-r-- 1 crifan crifan 43K Aug  9 00:54 libcgi.a
-rwxrwxr-x 1 crifan crifan 44K Aug  9 00:54 libcgi.so
crifan@ubuntu:libcgi-1.0$ ls /opt/crosscompile/libcgi/inclue/ -lh
total 0
crifan@ubuntu:libcgi-1.0$ gedit Makefile
crifan@ubuntu:libcgi-1.0$ make install
mkdir -p /opt/crosscompile/libcgi/lib
cp src/libcgi.a /opt/crosscompile/libcgi/lib
cp src/libcgi.so /opt/crosscompile/libcgi/lib
mkdir -p /opt/crosscompile/libcgi/include
cp src/cgi.h /opt/crosscompile/libcgi/include
cp src/session.h /opt/crosscompile/libcgi/include
crifan@ubuntu:libcgi-1.0$ ls /opt/crosscompile/libcgi/ -lh
total 12K
drwxrwxr-x 2 crifan crifan 4.0K Aug  9 00:57 include
drwxrwxr-x 2 crifan crifan 4.0K Aug  9 00:54 inclue
drwxrwxr-x 2 crifan crifan 4.0K Aug  9 00:54 lib
crifan@ubuntu:libcgi-1.0$ rm /opt/crosscompile/libcgi/inclue -fR

8.最后验证才是对的:

crifan@ubuntu:libcgi-1.0$ ls /opt/crosscompile/libcgi/ -lh
total 8.0K
drwxrwxr-x 2 crifan crifan 4.0K Aug  9 00:57 include
drwxrwxr-x 2 crifan crifan 4.0K Aug  9 00:54 lib
crifan@ubuntu:libcgi-1.0$ ls /opt/crosscompile/libcgi/include/ -lh
total 12K
-rwxrwxr-x 1 crifan crifan 4.3K Aug  9 00:57 cgi.h
-rwxrwxr-x 1 crifan crifan 1.1K Aug  9 00:57 session.h
crifan@ubuntu:libcgi-1.0$ ls /opt/crosscompile/libcgi/lib -lh
total 88K
-rw-rw-r-- 1 crifan crifan 43K Aug  9 00:57 libcgi.a
-rwxrwxr-x 1 crifan crifan 44K Aug  9 00:57 libcgi.so
crifan@ubuntu:libcgi-1.0$ 

 

【总结】

在Ubuntu下,交叉编译libcgi:

准备工作:

1. 去修改文件:

libcgi-1.0\src\string.c

中的587行的,从:

va_copy(bkp, str);

改为:

//va_copy(bkp, str);
va_copy(bkp, ptr);

以此避免:

【已解决】cygwin下用arm-xscale-linux-gnueabi交叉编译libcgi出错:src/string.c:587:2: error: incompatible type for argument 2 of ‘__builtin_va_copy’

2.去修改Makefile

从:

install:
	cp src/libcgi.a $(LIBDIR)
	cp src/libcgi.so $(LIBDIR)
	cp src/cgi.h $(INCDIR)
	cp src/session.h $(INCDIR)

变为:

install:
	mkdir -p $(LIBDIR)
	cp src/libcgi.a $(LIBDIR)
	cp src/libcgi.so $(LIBDIR)
	mkdir -p $(INCDIR)
	cp src/cgi.h $(INCDIR)
	cp src/session.h $(INCDIR)

以此避免:

后面make install时,会误将要安装的文件,不是拷贝到include和lib目录,而是拷贝成include和lib两个文件了。

 

过程:

1.配置:

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

2.编译:

make CC=arm-xscale-linux-gnueabi-gcc

3.安装:

make install
 


发表评论

电子邮件地址不会被公开。 必填项已用*标注

无觅相关文章插件,快速提升流量