cygwin에서arm-xscale-linux-gnueabi로 교차 컴파일libcgi

24114 단어

[배경]


뒤척이다
[기록] 교차 컴파일러arm-xscale-linux-gnueabi로 끼워넣는 리눅스 기반 무선HART 프로젝트를 교차 컴파일합니다
이 경우 include 경로에는 다음이 표시됩니다.
-I xxx/armxscalelibcgi/include
따라서 라이브러리libcgi가 필요합니다.
여기에는 이미 소스가 있습니다.libcgi-1.0
[뒤척이는 과정]
1. 먼저 코드와 설정을 살펴보자.
CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ ls
AUTHORS*  autogen.sh*  BUGS*  ChangeLog*  configure*  configure.in*  doc/  examples/  install-sh*  Makefile.in*  README*  src/  THANKS*  TODO*

CLi@PC-CLI-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 CLi@PC-CLI-1 ~/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는 지원되지 않습니다.
CLi@PC-CLI-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

테스트:
CLi@PC-CLI-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로 컴파일하기:
CLi@PC-CLI-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 $<

그래서 다시 설정해 보세요.
CLi@PC-CLI-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 매개 변수 추가
CLi@PC-CLI-1 ~/develop/libcgi/libcgi-1.0
$ make CC=arm-xscale-linux-gnueabi-gcc

결과적으로 다시 컴파일할 것이 없습니다.
CLi@PC-CLI-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. 그래서 클렌징에 가서:
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 {} \;

재구성:
CLi@PC-CLI-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 를 교차 컴파일할 수 있습니다.
CLi@PC-CLI-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는 번역이 끝났습니다.
지금 가서 설치를 시도해 보세요.
CLi@PC-CLI-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는 폴더가 아닌 파일이었다.
CLi@PC-CLI-1 ~/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

전재 대상:https://www.cnblogs.com/LxwEmbedded/p/4180020.html

좋은 웹페이지 즐겨찾기