cygwin下用arm-xscale-linux-gnueabi交叉编译libcgi

【背景】

折腾:

【记录】用交叉编译器arm-xscale-linux-gnueabi交叉编译一个基于嵌入式Linux的无线HART的项目

期间,却发现,include的路径中有:

-I xxx/armxscalelibcgi/include

所以,还需要一个库libcgi。

其中,此处已有源码:libcgi-1.0

【折腾过程】

1.先去看看代码和配置:

[email protected] ~/develop/libcgi/libcgi-1.0
$ ls
AUTHORS*  autogen.sh*  BUGS*  ChangeLog*  configure*  configure.in*  doc/  examples/  install-sh*  Makefile.in*  README*  src/  THANKS*  TODO*

[email protected]1 ~/develop/libcgi/libcgi-1.0
$ ./configure --help
Usage: configure [options] [host]
Options: [defaults in brackets after descriptions]
Configuration:
  --cache-file=FILE       cache test results in FILE
  --help                  print this message
  --no-create             do not create output files
  --quiet, --silent       do not print `checking...‘ messages
  --version               print the version of autoconf that created configure
Directory and file names:
  --prefix=PREFIX         install architecture-independent files in PREFIX
                          [/usr/local]
  --exec-prefix=EPREFIX   install architecture-dependent files in EPREFIX
                          [same as prefix]
  --bindir=DIR            user executables in DIR [EPREFIX/bin]
  --sbindir=DIR           system admin executables in DIR [EPREFIX/sbin]
  --libexecdir=DIR        program executables in DIR [EPREFIX/libexec]
  --datadir=DIR           read-only architecture-independent data in DIR
                          [PREFIX/share]
  --sysconfdir=DIR        read-only single-machine data in DIR [PREFIX/etc]
  --sharedstatedir=DIR    modifiable architecture-independent data in DIR
                          [PREFIX/com]
  --localstatedir=DIR     modifiable single-machine data in DIR [PREFIX/var]
  --libdir=DIR            object code libraries in DIR [EPREFIX/lib]
  --includedir=DIR        C header files in DIR [PREFIX/include]
  --oldincludedir=DIR     C header files for non-gcc in DIR [/usr/include]
  --infodir=DIR           info documentation in DIR [PREFIX/info]
  --mandir=DIR            man documentation in DIR [PREFIX/man]
  --srcdir=DIR            find the sources in DIR [configure dir or ..]
  --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
Host type:
  --build=BUILD           configure for building on BUILD [BUILD=HOST]
  --host=HOST             configure for HOST [guessed]
  --target=TARGET         configure for TARGET [TARGET=HOST]
Features and packages:
  --disable-FEATURE       do not include FEATURE (same as --enable-FEATURE=no)
  --enable-FEATURE[=ARG]  include FEATURE [ARG=yes]
  --with-PACKAGE[=ARG]    use PACKAGE [ARG=yes]
  --without-PACKAGE       do not use PACKAGE (same as --with-PACKAGE=no)
  --x-includes=DIR        X include files are in DIR
  --x-libraries=DIR       X library files are in DIR

[email protected] ~/develop/libcgi/libcgi-1.0
$

2.直接去配置:

./configure --prefix=$HOME/develop/crosstool-ng/x-tools/libcgi --build=i686-pc-cygwin --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi CC=arm-xscale-linux-gnueabi-gcc

结果说是不支持这个CC:

[email protected]1 ~/develop/libcgi/libcgi-1.0
$ ./configure --prefix=$HOME/develop/crosstool-ng/x-tools/libcgi --build=i686-pc-cygwin --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi CC=arm-xscale-linux-gnueabi-gcc
configure: warning: CC=arm-xscale-linux-gnueabi-gcc: invalid host type
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

3.所以,去掉CC:

./configure --prefix=$HOME/develop/crosstool-ng/x-tools/libcgi --build=i686-pc-cygwin --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi

试试:

[email protected]1 ~/develop/libcgi/libcgi-1.0
$ ./configure --prefix=$HOME/develop/crosstool-ng/x-tools/libcgi --build=i686-pc-cygwin --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi
loading cache ./config.cache
checking for gcc... (cached) 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... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for a BSD compatible install... (cached) /usr/bin/install -c
checking how to run the C preprocessor... (cached) gcc -E
checking for ANSI C header files... (cached) yes
creating ./config.status
creating Makefile
creating src/config.h
src/config.h is unchanged

4.然后再去make编译:

[email protected]1 ~/develop/libcgi/libcgi-1.0
$ make
cc    -c -o src/error.o src/error.c
cc    -c -o src/cgi.o src/cgi.c
cc    -c -o src/session.o src/session.c
cc    -c -o src/base64.o src/base64.c
cc    -c -o src/md5.o src/md5.c
cc    -c -o src/string.o src/string.c
cc    -c -o src/general.o src/general.c
cc    -c -o src/list.o src/list.c
cc    -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
cc -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  |
+-------------------------------------------------------------------+

和明显,不是交叉编译。

5.去看了下,.o,也的确只是x86的,不是arm的:

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ file src/
base64.c     cgi.c        cgi.o        config.h.in  cookie.o     error.h      general.c    libcgi.a     list.c       md5.c        session.c    session.o    string.o
base64.o     cgi.h        config.h     cookie.c     error.c      error.o      general.o    libcgi.so    list.o       md5.o        session.h    string.c

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ file src/cgi.o
src/cgi.o: 80386 COFF executable not stripped - version 30821

6.参考:

How to libcgi?

以及去看了:

libcgi-1.0\Makefile

中的:

.c.o: $(CC) $(FLAGS) -c $<

所以,去重新配置一下:

[email protected]1 ~/develop/libcgi/libcgi-1.0
$ ./configure --prefix=$HOME/develop/crosstool-ng/x-tools/libcgi --build=i686-pc-cygwin --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi
loading cache ./config.cache
checking for gcc... (cached) 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... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for a BSD compatible install... (cached) /usr/bin/install -c
checking how to run the C preprocessor... (cached) gcc -E
checking for ANSI C header files... (cached) yes
creating ./config.status
creating Makefile
creating src/config.h
src/config.h is unchanged

7.然后再在make的时候加上CC参数

[email protected]1 ~/develop/libcgi/libcgi-1.0
$ make CC=arm-xscale-linux-gnueabi-gcc

结果没东西需要重新编译的:

[email protected]1 ~/develop/libcgi/libcgi-1.0
$ make CC=arm-xscale-linux-gnueabi-gcc

+---------------------------------------+
|       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  |
+-------------------------------------------------------------------+

8.所以去clean一把:

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ make clean
find src/ -name *.*o -exec rm -f {} \;
find src/ -name *.a -exec rm -f {} \;

再重新配置:

[email protected]1 ~/develop/libcgi/libcgi-1.0
$ ./configure --prefix=$HOME/develop/crosstool-ng/x-tools/libcgi --build=i686-pc-cygwin --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi
loading cache ./config.cache
checking for gcc... (cached) 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... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for a BSD compatible install... (cached) /usr/bin/install -c
checking how to run the C preprocessor... (cached) gcc -E
checking for ANSI C header files... (cached) yes
creating ./config.status
creating Makefile
creating src/config.h
src/config.h is unchanged

make加CC,然后可以交叉编译了:

[email protected]1 ~/develop/libcgi/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

9.但是结果出错问题了:

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

10.make是编译完了。

现在去试试安装:

[email protected]1 ~/develop/libcgi/libcgi-1.0
$ make install
cp src/libcgi.a /home/CLi/develop/crosstool-ng/x-tools/libcgi/lib
cp src/libcgi.so /home/CLi/develop/crosstool-ng/x-tools/libcgi/lib
cp src/cgi.h /home/CLi/develop/crosstool-ng/x-tools/libcgi/include
cp src/session.h /home/CLi/develop/crosstool-ng/x-tools/libcgi/include

11.本以为OK了,但是突然坑爹的发现,安装目录中lib和include,都是文件,而不是文件夹:

[email protected] ~/develop/libcgi/libcgi-1.0
$ ll /home/CLi/develop/crosstool-ng/x-tools/libcgi
total 48K
-rwxr-xr-x 1 CLi Domänen-Benutzer 1.1K Aug  6 12:59 include*
-rw-r--r-- 1 CLi Domänen-Benutzer  44K Aug  6 12:59 lib

所以,删除掉此两个文件,新建两个文件夹,手动重新拷贝试试:

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ rm /home/CLi/develop/crosstool-ng/x-tools/libcgi/*

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ ll /home/CLi/develop/crosstool-ng/x-tools/libcgi
total 0

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ mkdir /home/CLi/develop/crosstool-ng/x-tools/libcgi/lib

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ mkdir /home/CLi/develop/crosstool-ng/x-tools/libcgi/include

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ cp src/libcgi.a /home/CLi/develop/crosstool-ng/x-tools/libcgi/lib/

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ cp src/libcgi.so /home/CLi/develop/crosstool-ng/x-tools/libcgi/lib/

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ cp src/cgi.h /home/CLi/develop/crosstool-ng/x-tools/libcgi/include/

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ cp src/session.h /home/CLi/develop/crosstool-ng/x-tools/libcgi/include/

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ ll /home/CLi/develop/crosstool-ng/x-tools/libcgi
total 0
drwxr-xr-x+ 1 CLi Domänen-Benutzer 0 Aug  6 13:04 include/
drwxr-xr-x+ 1 CLi Domänen-Benutzer 0 Aug  6 13:03 lib/

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ ll /home/CLi/develop/crosstool-ng/x-tools/libcgi/include/
total 12K
-rwxr-xr-x 1 CLi Domänen-Benutzer 4.3K Aug  6 13:04 cgi.h*
-rwxr-xr-x 1 CLi Domänen-Benutzer 1.1K Aug  6 13:04 session.h*

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ ll /home/CLi/develop/crosstool-ng/x-tools/libcgi/lib
total 88K
-rw-r--r-- 1 CLi Domänen-Benutzer 43K Aug  6 13:03 libcgi.a
-rwxr-xr-x 1 CLi Domänen-Benutzer 44K Aug  6 13:03 libcgi.so*

如此,才算成功:

有了对应的.a和.so的库,有了对应的.h文件。

->

很明显是makefile写错了。

12.去折腾了下,测试结果是,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)

就可以了。

其中:

(1)对应的uninstall部分,没去管;

(2)由于makefile文件,也是configure生成的,所以,最终的修改,应该是修改configure文件。此处不熟悉,暂不去深究了。

效果是:

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ rm /home/CLi/develop/crosstool-ng/x-tools/libcgi/* -fr

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ ll /home/CLi/develop/crosstool-ng/x-tools/libcgi
total 0

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ ll /home/CLi/develop/crosstool-ng/x-tools/libcgi^C

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ make install
mkdir -p /home/CLi/develop/crosstool-ng/x-tools/libcgi/lib
cp src/libcgi.a /home/CLi/develop/crosstool-ng/x-tools/libcgi/lib
cp src/libcgi.so /home/CLi/develop/crosstool-ng/x-tools/libcgi/lib
mkdir -p /home/CLi/develop/crosstool-ng/x-tools/libcgi/include
cp src/cgi.h /home/CLi/develop/crosstool-ng/x-tools/libcgi/include
cp src/session.h /home/CLi/develop/crosstool-ng/x-tools/libcgi/include

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ ll /home/CLi/develop/crosstool-ng/x-tools/libcgi
total 0
drwxr-xr-x+ 1 CLi Domänen-Benutzer 0 Aug  6 13:10 include/
drwxr-xr-x+ 1 CLi Domänen-Benutzer 0 Aug  6 13:10 lib/

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ ll /home/CLi/develop/crosstool-ng/x-tools/libcgi/lib/
total 88K
-rw-r--r-- 1 CLi Domänen-Benutzer 43K Aug  6 13:10 libcgi.a
-rwxr-xr-x 1 CLi Domänen-Benutzer 44K Aug  6 13:10 libcgi.so*

CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ ll /home/CLi/develop/crosstool-ng/x-tools/libcgi/include/
total 12K
-rwxr-xr-x 1 CLi Domänen-Benutzer 4.3K Aug  6 13:10 cgi.h*
-rwxr-xr-x 1 CLi Domänen-Benutzer 1.1K Aug  6 13:10 session.h*

【总结】

此处的过程是:

1.配置:

./configure --prefix=$HOME/develop/crosstool-ng/x-tools/libcgi --build=i686-pc-cygwin --target=arm-xscale-linux-gnueabi --host=arm-xscale-linux-gnueabi

注:此处指定CC的话,无法识别,所以CC的指定,放在make后面了。

2.编译:

准备工作:

(1)修改:

libcgi-1.0\src\string.c

中的587行的:

va_copy(bkp, str);

改为:

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

编译:

再去指定CC,去make编译:

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

3.安装:

准备工作:

将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
时间: 2024-11-08 13:54:08

cygwin下用arm-xscale-linux-gnueabi交叉编译libcgi的相关文章

Cygwin 下的 自动安装工具 apt-cyg

类似 于apt-get 或者 yum Cygwin可以在Windows下使用unix环境Bash和各种功能强大的工具,对于Linux管理员来说不想使用Linux桌面是必备的工具. Cygwin下也有类似Linux下包管理工具apt-cyg,可以方便的通过网络安装各种软件. 1.下载安装:http://cygwin.com/setup.exe 2.选择安装源及软件,如需安装apt-cyg需安装以下软件包: wget tar gawk bzip2 3.Cygwin安装完成后打开Cygwin Term

Linux下获取arm的交叉编译工具链

转载请注明文章:Linux下获取arm的交叉编译工具链 出处:多客博图 这里介绍,Linux下获取arm的交叉编译工具链,比如arm-linux-gnueabihf-gcc.arm-linux-gneabihf-gcc等. 前言 这里有一个专门的说法: “arm-linux-gnueabihf-gcc是由 Linaro 公司基于GCC推出的的ARM交叉编译工具.可用于交叉编译ARM系统中所有环节的代码,包括裸机程序.u-boot.Linux kernel.filesystem和App应用程序.使

浅析 Linux 下的 arm 交叉编译工具

什么是交叉编译工具 http://elinux.org/Toolchains 要解释交叉编译工具,我们首先要理解三个基本概念: 编译平台:是指该编译器是在哪个平台编译出来的 编译主机:编译器运行在哪个平台 目标平台:编译器为哪个平台产生代码 比如我们在 Ubuntu(Linux) 下编译 arm 开发板的程序,那么: 编译平台就是 X86,该编译器在 x86上运行 编译主机就是这台运行 Ubuntu Linux 的电脑 目标平台就是 arm 开发板 所以通常所指的交叉编译,就是在该平台编译生成在

NTP 4.2.8p9在cygwin下的交叉编译

简介:NTP(Network Time Protocol)是指网络时间协议,是PC.手持设备.其他终端或者服务器来校准时间的协议.如,windows和linux系统都有对应的时间校准,使用的都是NTP协议.NTP协议的基于C来实现,代码跨平台,可在windows.linux以及其他平台上编译运行.NTP的官方协议实现库,当前最新版本是4.2.8p9.NTP4.2.8p9出于安全性的考虑,该版本依赖于openssl的库,经笔者试验openssl 0.98的版本支持不了,用openssl1.1.0e

在Ubentu环境下创建arm交叉编译环境

学校:华中科技大学机械学院 作业任务:在Ubentu环境下创建arm交叉编译环境并且在虚拟机中编译例程 首先,利用U盘安装windows10+Ubuntu16.04双系统,系统刚开始安装,需要执行以下两个指令以完成相应软件的更新 # sudo apt-get update# sudo apt-get upgrade 之后输入 # sudo apt-get install build-essential git # sudo apt-get install gcc-arm-none-eabi 完成

Cygwin下使用rsync备份至Linux server时的中文编码问题

14年6月10日 今天在备份数据又出了状况:所有文件名中含有非英文字符的文件都被从Linux server上删除,而当要重新拷贝Windows下该文件时,则显示错误: invalid or incomplete multibyte or wide character 看来是文件名编码出了问题.在Cygwin下查看locale,被设置成了[email protected].而原先设置的是什么也不记得了,但肯定是设置系统locale为Chinese又切换到English造成的.同时发现,date命令

[转载]arm交叉编译器gnueabi、none-eabi、arm-eabi、gnueabihf、gnueabi区别

arm交叉编译器gnueabi.none-eabi.arm-eabi.gnueabihf.gnueabi区别 (http://www.veryarm.com/296.html) 命名规则 交叉编译工具链的命名规则为:arch [-vendor] [-os] [-(gnu)eabi] arch - 体系架构,如ARM,MIPS vendor - 工具链提供商 os - 目标操作系统 eabi - 嵌入式应用二进制接口(Embedded Application Binary Interface) 根

arm驱动linux异步通知与异步IO【转】

转自:http://blog.csdn.net/chinazhangzhong123/article/details/51638793 <[ arm驱动] linux异步通知与 异步IO>涉及内核驱动函数二个,内核结构体一个,分析了内核驱动函数二个:可参考的相关应用程序模板或内核驱动模板二个,可参考的相关应用程序模板或内核驱动三个 描述:设备文件IO访问:阻塞与非阻塞io访问,poll函数提供较好的解决设备访问的机制,但是如果有了异步通知整套机制就更加完整了 一.阻塞 I/O,非阻塞IO,异步

Cygwin下编译的程序不使用Cygwin.dll即可运行的命令 及常用命令简介

cc -mno-cygwin foo.c 1.$ ps PS的相关用法: QuoteUsage ps [-aefl] [-u uid]-f = show process uids, ppids-l = show process uids, ppids, pgids, winpids-u uid = list processes owned by uid-a, -e = show processes of all users-s = show process summary-W = show wi