收藏 分享(赏)

Cygwin下用crosstool-ng编译交叉工具链.doc

上传人:j35w19 文档编号:7805970 上传时间:2019-05-26 格式:DOC 页数:19 大小:129.50KB
下载 相关 举报
Cygwin下用crosstool-ng编译交叉工具链.doc_第1页
第1页 / 共19页
Cygwin下用crosstool-ng编译交叉工具链.doc_第2页
第2页 / 共19页
Cygwin下用crosstool-ng编译交叉工具链.doc_第3页
第3页 / 共19页
Cygwin下用crosstool-ng编译交叉工具链.doc_第4页
第4页 / 共19页
Cygwin下用crosstool-ng编译交叉工具链.doc_第5页
第5页 / 共19页
点击查看更多>>
资源描述

1、Cygwin 下用 crosstool-ng 编译交叉工具链Cywin 版本:1.7.7(CYGWIN_NT-5.1)Crosstool-ng 版本:1.9.3操作系统:Windows XP SP3一、下载 crosstool-ngcrosstool-ng 的下载地址是:http:/ymorin.is-a-geek.org/download/crosstool-ng/值得注意的是,下载里最新的 crosstool-ng 以后,记得到http:/ymorin.is-a-geek.org/download/crosstool-ng/01-fixes/ 看看有没有相应的补丁,有得话一起下载下来。本次

2、下载的版本是 1.9.3 无 patch。二、准备 crosstool-ng 的安装环境使用 crosstool-ng 必须安装一些开发应用工具:grep,sed,bash,make,gcc,awk,bison,flex,makeinfo,automake,libtool,curl,cvs,patch,gzip,bzip2,liblzma1,ncurses(对应的库也要装上)三、安装 crosstool-ng$ mkdir /croosstool-ng # 在当前用户目录下建立 croosstool-ng 目录$ cd /croosstool-ng$ mv /tmp/crosstool-ng-

3、1.9.3.tar.bz2 ./ #把下载的 crosstool-ng 软件包放到 crosstool-ng 目录中$ tar -jxvf crosstool-ng-1.9.3.tar.bz2 # 解包$ cd crosstool-ng-1.9.3 # 进入解压目录$ patch -p1 # 给 crosstool-ng 打补丁(如果有)$ ./configure -prefix=/opt/crosstool-ng # 配置 crosstool-ng$ make # 编译 crosstool-ng$ make install # 安装 crosstool-ng$ echo “PATH=$PAT

4、H:/opt/crosstool-ng/bin“ /.bashrc # 为后面调用 ct-ng 命令增加环境变量$ source /.bashrc$ ct-ng helpThis is crosstool-NG version 1.9.3Copyright (C) 2008 Yann E. MORIN This is free software; see the source for copying conditions.There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR APARTICULAR PURPOSE.到

5、此,我们已经成功迈出一大步,好戏还在后头,加油!四、配置交叉编译工具链$ cd /croosstool-ng$ mkdir crosstool-ng-1.9.3_build # 建立一个交叉工具链的输出目录$ mkdir src # 建立保存源码包目录$ mkdir x-tools # 建立交叉编译器的安装路径$ cd crosstool-ng-1.9.3_build/$ cp /opt/crosstool-ng/lib/ct-ng-1.9.3/samples/arm-unknown-linux-gnueabi/crosstool.config .config$ ct-ng menuconfi

6、g此时会出现 crosstool-ng 的配置窗口,针对 armv4t 体系架构,开始对其进行修改配置:1、已下载好的源码包路径和交叉编译器的安装路径。Paths and misc options -($HOME/crosstool-ng/src) Local tarballs directory 保存源码包路径($HOME/crosstool-ng/x-tools/$CT_TARGET) Prefix directory 交叉编译器的安装路径2、修改交叉编译器针对的构架Target options -* Target optimisations *(armv4t) Architecture

7、level (arm9tdmi) Emit assembly for CPU (arm920t) Tune for CPU通过查找资料,这个应该是指令集的架构,对于 S3C2410/S3C2440,都是 ARM920T 的核心,架构指令是 armv4t,所以,如果要编译 2410/2440 的,就选 armv4t。以此类推S3C6410 ARM1176JZF-S 核心 使用的是 armv6 架构,就选 armv6,那么具体都支持哪些架构呢?可以用 man gcc 来查询,搜索 arm,再搜索-march=就可以找到本 gcc 支持的处理器核心列表了。3、增加编译时的并行进程数,以增加运行效率,

8、加快编译。Paths and misc options -* Build behavior * (4) Number of parallel jobs 这个数值不宜过大,应该为 CPU 数量的两倍。由于我的 CPU 是双核的,所以我填了 4.4、一些个性化的修改(可以不修改)Toolchain options -* Tuple completion and aliasing * (apollo) Tuples vendor string 这样产生的编译器前缀就是:arm-apollo-linux-gnueabi-5、 C compiler -(crosstool-NG-$CT_VERSION-

9、apollo) gcc ID string以上红色字体部分即为修改之处。以上步骤基本都是直接从在 fedora12 下用 crosstool-ng 建立 arm-linux 交叉编译环境 copy,只对少部分做了修改。五、其它配置:这些都是根据我自己的需要添加的,所以和上面的步骤分开单独写。1、设置 croostool-NG 调试标记Paths and misc options -*crosstool-Ng behavior*Debug crosstool-NG #*Save intermediate steps #保存编译过程中的中间步骤,在没选中上一项之前,这一项不出现。如果你足够幸运,第

10、一次就能编译通过,这一步就没有必要选。如果很不幸,中间出现了错,这一步就显得相当重要了,可以让节省很多时间。因为有了这一项,在编译的过程中,croostool-ng 会记录下每一步的状态。这样在对出现的错误进行纠正后,就可以从出错这一步开再继续编译,当然你也可以从任一个已保存的状态点开始。如果没有选这一项的话,每出错一次就要从头重新开始编译,这可是相当浪费时间。2、设置其他支持的语言C compiler -* Additional supported languages:* C+ Fortran Java这里我只选了 C+,把 Fortran,Java 去掉了。如果选上 Java 的话在编译到

11、Installing final compiler这一步时会出错,我第一次是在 linux 下编译的,因为我不需要支持 Java,所以我就直接把 Java 这一项去掉了,没有找解决方法。3、配置交叉工具链里的调试工具Debug facilitites - * dmalloc - * duma - * gdb - ltrace - # ltrace 目前只支持 linux 系统 * strace -六、准备源码编译虽然 crosstool-ng 有自动下载源码的功能,但速度非常慢,还是建议自己把源码下载过来。binutils-2.19.1.tar.bz2dmalloc-5.5.2.tgzduma

12、_2_5_15.tar.gzexpat-2.0.1.tar.gzgcc-4.3.2.tar.bz2gdb-6.8.tar.bz2glibc-2.9.tar.bz2glibc-ports-2.9.tar.bz2gmp-4.3.2.tar.bz2libelf-0.8.13.tar.gzlinux-2.6.33.7.tar.bz2mpfr-2.4.2.tar.bz2ncurses-5.7.tar.gzSstrip.cstrace-4.5.19.tar.bz2如果上面的链接失效,你可以通过http:/www.kernel.org/pub/linux/kernel/http:/ftp.gnu.org/g

13、nu/ 下载到大部分所需要的源码,其他再百度或 Google 就可以轻松搞定。下面还不能编译,因为还有重要的一步没有做:修改 duma_2_5_15.tar.gz 的 Makefile 文件$ tar -zxvf duma_2_5_15.tar.gz$ cd duma_2_5_15打开“GNUmakefile” ,添加对 cygwin 的支持,也就是添加下面红色的一句# some defaults:CC=gccCXX=g+AR=arRANLIB=ranlibINSTALL=installRM=rmRMFORCE=rm -fECHO=echoECHOLF=echoOS=cygwin接下来重新把

14、duma_2_5_15 打包$ cd $ tar -zcvf duma_2_5_15.tar.gz duma_2_5_15为什么要这样做可以参看 duma_2_5_15 下的 INSTALL 文件下面把所有的源码放到/home/Administrator/crosstool-ng/src目录下,也就是上面创建的 src 目录下面就可以开始编译了Ct-ng build.44 代表同时运行 4 个进程进行编译。下面就是漫长的等待了。七、增加环境变量 $echo “PATH=$PATH:$HOME/crosstool-ng/x-tools/arm-apollo-linux-gnueabi/bin“

15、/.bashrc。OK,大功造成,是否该测试一下呢,简单:$ arm-apollo-linux-gnueabi-gcc -v Using built-in specs.Target: arm-apollo-linux-gnueabiConfigured with: /home/Administrator/ct-ng-1.9.3/crosstool-ng/crosstool-ng-1.9.3_build/targets/src/gcc-4.3.2/configure -build=i686-build_pc-cygwin -host=i686-build_pc-cygwin -target=ar

16、m-apollo-linux-gnueabi -prefix=/home/Administrator/ct-ng-1.9.3/crosstool-ng/x-tools/arm-apollo-linux-gnueabi -with-sysroot=/home/Administrator/ct-ng-1.9.3/crosstool-ng/x-tools/arm-apollo-linux-gnueabi/arm-apollo -linux-gnueabi/sys-root -enable-languages=c,c+ -disable-multilib -with-arch=armv4t -with

17、-cpu=arm9tdmi -with-tune=arm920t -with-float=soft -with-pkgversion=crosstool-NG-1.9.3-apollo -disable-sjlj-exceptions -enable-_cxa_atexit -disable-libmudflap -disable-libgomp -disable-libssp -with-gmp=/home/Administrator/ct-ng-1.9.3/crosstool-ng/crosstool-ng-1.9.3_build/targets/arm-apollo-linux-gnue

18、abi/build/static -with-mpfr=/home/Administrator/ct-ng-1.9.3/crosstool-ng/crosstool-ng-1.9.3_build/targets/arm-apollo-linux-gnueabi/build/static -enable-threads=posix -enable-target-optspace -with-local-prefix=/home/Administrator/ct-ng-1.9.3/crosstool-ng/x-tools/arm-apollo-linux-gnueabi/arm-apollo-li

19、nux-gnueabi/sys-root -disable-nls -enable-symvers=gnu -enable-c99 -enable-long-long Thread model: posixgcc version 4.3.2 (crosstool-NG-1.9.3-apollo)八、错误及解决方法1、配置 crosstool-ng 产生的错误1.1 ncurses headers files were not foundChecking for ncurses/ncurses.h. noChecking for ncurses/curses.h. noChecking for

20、ncurses.h. noChecking for curses.h. noncurses headers files were not found解决方法:安装:ncurses, 、libncurses-devel1.2 flex none foundChecking for flex. Noflex: none foundEither you are missing entirely the needed tool,or the version you have is too old.configure: Bailing out.解决方法:安装:flex,flexdll1.3 automa

21、ke 1.10 or above was not foundChecking for automake. noautomake 1.10 or above was not foundEither you are missing entirely the needed tool,or the version you have is too old.configure: Bailing out.解决方法:安装:automake1.4 libtool 1.5.26 or above was not foundChecking for libtool. nolibtool 1.5.26 or abov

22、e was not foundEither you are missing entirely the needed tool,or the version you have is too old.You can give the path to this tool using: -with-libtool=PATHconfigure: Bailing out.解决方法:安装:libtool注:在配置 crosstool-NG 时,出现的类似 “XXX:none found”的错误,都可以是该工具没有安装,把该工具安装上,重新配置即可。1.5 ct-ng help 命令检查时出错crosstoo

23、l-ng 安装成功后,用 ct-ng help 命令检查时,不认识该命令这多半是添加环境变量失败造成的,这时可以打开/home/Administrator目录下的.bashrc 查看是否把 windows 里的其他环境变量添加到了.bashrc 文件中,如果把多余的去掉,只保留 cgywin 自己的环境变量,如下所示:PATH=/usr/local/bin:/usr/bin:/bin:/opt/crosstool-ng-1.9.3/bin1.6 配置时的其他错误在配置 crosstool-NG 时,也即执行./configure -prefix=/opt/crosstool-ng出现的类似“X

24、XX:none found”的错误,都是相应工具没有安装造成的,重新运行setup.exe 把该工具安装上,再执行该命令,即可。2、编译交叉工具链产生的错误2.1 targets is *not* case-sensitiveCygwin 窗口的错误信息:$ ct-ng buildINFO Performing some trivial sanity checksERROR Your file system in /home/Administrator/croosstool-ng/crosstool-ng-1.9.3/targets is *not* case-sensitive!00:02

25、/ make: * build Error 1unix 和 Linux 都是区分大小写的,cygwin 既然是模拟 unix 环境,当然也是区分大小定的。这个问题好解决,修改一下注册表就行了。打开注册表,找到如下位置:HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession ManagerKernel把“obcaseinsensitive”的值改为 0,再重新启动电脑,cygwin 下就区分大小写了。如果觉得麻烦,可以把如下代码复制到记事本里(case-sensitive.txt):Windows Registry Editor Versi

26、on 5.00HKEY_LOCAL_MACHINESYSTEMCurrentControlSetControlSession Managerkernel“obcaseinsensitive“=dword:00000000然后把记事本的后缀名改为.reg,(case-sensitive.reg),双击 reg(case-sensitive.reg)文件即可,和上面的效果一样。2.1 Installing static core C compiler failedCygwin 窗口的错误信息:INFO Installing static core C compilerEXTRA Configuri

27、ng static core C compilerERROR checking for C compiler default output file name. configure: error: C compiler cannot create executablesconf.tab.oERROR Build failed in step Installing static core C compilerERROR Error happened in /opt/crosstool-ng/lib/ct-ng-1.9.1/scripts/functions in function CT_DoEx

28、ecLog (line unknown, sorry)x.oERROR called from /opt/crosstool-ng/lib/ct-ng-1.9.1/scripts/build/cc/gcc.shat line # 203 in function do_cc_coreil.oERROR called from /opt/crosstool-ng/lib/ct-ng-1.9.1/scripts/build/cc/gcc.sh at line # 52 in function do_cc_core_pass_1ERROR called from /opt/crosstool-ng/l

29、ib/ct-ng-1.9.1/scripts/crosstool-NG.sh at line # 597 in function mainERROR Look at /home/Administrator/crosstool-ng/x-tools/arm-apollo-linux-gnueabi/build.log for more info on this error.解决办法:安装 gcc4-g+,在编译的时候时需要 C+的参考:http:/ Build failed in step Installing D.U.M.A.Cygwin 窗口的错误信息:INFO Installing D.U

30、.M.A.EXTRA Copying sourcesERROR Build failed in step Installing D.U.M.A.ERRORError happened in /opt/crosstool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/build/debug/200-duma.sh in function do_debug_duma_build (line unknown, sorry)ERROR called from /opt/crosstool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/build/debug.sh

31、 at line # 35 in function do_debugERROR called from /opt/crosstool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/crosstool-NG.sh at line # 597 in function mainERROR Look at /home/Administrator/ct-ng-1.9.3/crosstool-ng/x-tools/arm-apollo-linux-gnueabi/build.log for more info on this error.ERROR (elapsed: 479:03.4

32、2)479:07 / make: * build Error 1Build.log 中的提示如下:INFO Installing D.U.M.A.EXTRA Copying sourcesERROR Build failed in step Installing D.U.M.A.ERROR Error happened in /opt/crosstool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/build/debug/200-duma.sh in function do_debug_duma_build (line unknown, sorry)ERROR calle

33、d from /opt/crosstool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/build/debug.sh at line # 35 in function do_debugERROR called from /opt/crosstool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/crosstool-NG.sh at line # 597 in function mainERROR Look at /home/Administrator/ct-ng-1.9.3/crosstool-ng/x-tools/arm-apollo-linux-g

34、nueabi/build.log for more info on this error.ERROR (elapsed: 479:03.42)解决方法:修改 DUMA 的 Makefile 文件:$ tar -zxvf duma_2_5_15.tar.gz #解压源码包$ cd duma_2_5_15打开“GNUmakefile” ,添加对 cygwin 的支持,也就是添加下面红色的一句# some defaults:CC=gccCXX=g+AR=arRANLIB=ranlibINSTALL=installRM=rmRMFORCE=rm -fECHO=echoECHOLF=echoOS=cyg

35、win接下来重新把 duma_2_5_15 打包$ cd $ tar -zcvf duma_2_5_15.tar.gz duma_2_5_15 #重新压缩源码这个错误让我郁闷了几天,因为在 build.log 文件里的信息也没说出问题可能出在什么地方。最后才在 INSTALL 文件里发现如果是在 cygwin 下编译需要修改 Makefile 文件INSTALL 文件的部分内容:his documents describes if and how the library is installed on your system.I. Linux/Unix environments (includ

36、ing Cygwin and MinGW):Configure the options by editing the Makefile.Read carefully the description of options at top of the Makefile.Take care for the special OS/OSTYPE depending sections.Especially if you are going to use the LD_PRELOAD mechanism.Call GNU make often called gmake for building the li

37、brary.GNU make is called mingw32-make for MinGW.Add option OSTYPE=msys when calling make for MinGW.Add option OSTYPE=cygwin when calling make for Cygwin.Add option OS=osx when calling make for MacOS X or Darwin.Add option OS=freebsd when calling make for FreeBSD.Add option OS=netbsd when calling mak

38、e for NetBSD.Add option OS=solaris when calling make for Solaris.2.3 Build failed in step Installing ltraceCygwin 窗口的错误信息:INFO Installing ltraceEXTRA Copying sources to build dirEXTRA Configuring ltraceEXTRA Building ltraceERROR make1: * sysdeps/sysdep.o Error 2ERROR Build failed in step Installing

39、ltraceERROR Error happened in /opt/crosstool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/functions in function CT_DoExecLog (line unknown, sorry)ERROR called from /opt/crosstool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/build/debug/400-ltrace.sh at line # 52 in function do_debug_ltrace_buildERROR called from /opt/cross

40、tool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/build/debug.sh at line # 35 in function do_debugERROR called from /opt/crosstool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/crosstool-NG.sh at line # 597 in function mainERROR Look at /home/Administrator/ct-ng-1.9.3/crosstool-ng/x-tools/arm-apollo-linux-gnueabi/build.log

41、for more info on this error.ERROR (elapsed: 591:35.21)591:39 / make: * build Error 2Build.log 中的提示如下:ALL make1: Entering directory /home/Administrator/ct-ng-1.9.3/crosstool-ng/crosstool-ng-1.9.3_build/ targets/arm-apollo-linux-gnueabi/build/build-ltraceALL arm-apollo-linux-gnueabi-gcc -Wall -g -O2 -

42、iquote /home/Administrator/ct-ng-1.9.3/crosstool-ng/crosstool-ng-1.9.3_build/targets/arm-apollo-linux-gnueabi/build/build-ltrace -iquote /home/Administrator/ct-ng-1.9.3/crosstool-ng/crosstool-ng-1.9.3_build/targets/arm-apollo-linux-gnueabi/build/build-ltrace/sysdeps/CYGWIN_NT-5.1 -DSYSCONFDIR=“/usr/

43、etc“ -c -o main.o main.cALL /usr/bin/make -C sysdeps/CYGWIN_NT-5.1ALL make: Entering an unknown directoryALL make: * sysdeps/CYGWIN_NT-5.1: No such file or directory. Stop.ALL make: Leaving an unknown directoryERROR make1: * sysdeps/sysdep.o Error 2ALL make1: Leaving directory /home/Administrator/ct

44、-ng-1.9.3/crosstool-ng/crosstool-ng-1.9.3_build/targets/arm-apollo-linux-gnueabi/build/build-ltraceERROR Build failed in step Installing ltraceERROR Error happened in /opt/crosstool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/functions in function CT_DoExecLog (line unknown, sorry)ERROR called from /opt/crosst

45、ool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/build/debug/400-ltrace.sh at line # 52 in function do_debug_ltrace_buildERROR called from /opt/crosstool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/build/debug.sh at line # 35 in function do_debugERROR called from /opt/crosstool-ng-1.9.3/lib/ct-ng-1.9.3/scripts/crosstool-N

46、G.sh at line # 597 in function mainERROR Look at /home/Administrator/ct-ng-1.9.3/crosstool-ng/x-tools/arm-apollo-linux-gnueabi/build.log for more info on this error.ERROR (elapsed: 591:39)解决方法:在配置文件中把 ltrace 这一项去掉,原因很简单,ltrace 不支持 windows,只支持 linux,在README 文件中有说明,之所以能知道这个是受解决上一个错误的启发,查看了 ltrace 的REA

47、DME 文件,原文如下:4. Where does it work-It works with ELF based Linux systems running on i386, m68k, S/390,ARM, PowerPC, PowerPC64, IA64, AMD64, SPARC and Alpha processors.It is part of at least Debian GNU/Linux, RedHat, SuSE, Mandrake.2.4 Build failed in step Installing libelf for the targetCygwin 窗口的错误信息:INFO Installing libelf for the targetEXTRA Configuring libelfEXTRA Building libelfERROR make2: * de.cat Segmentation fault (core dumped)ERROR make1: * all-recursive Error 1ERROR Build failed in step Installing libel

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 企业管理 > 管理学资料

本站链接:文库   一言   我酷   合作


客服QQ:2549714901微博号:道客多多官方知乎号:道客多多

经营许可证编号: 粤ICP备2021046453号世界地图

道客多多©版权所有2020-2025营业执照举报