- 进入cygwin根目录
$ cd /
- 建立三个子目录
$ mkdir –p /src/binutils /src/gcc /src/gdb
-p表示如果父目录不存在,则建立父目录
- 解压相应的压缩文件到不同的子目录,e表示e盘,即CD-ROM
GNU Binary Utilities Unzip
$ cd /src/binutils
$ tar xjvf /cygdrive/e/gnu/source/binutils-2.11.2a.tar.bz2
参数说明
-x extaract files from an archive
-j filter the archive through bzip2
-v 即verbose,verbosely list files processed
-f use archive file
则会在src/binutils下建立子目录binutils-2.11.2a,其中包含了GNU
Binutils source file
GNU C/C++ Compile Unzip
$ cd /src/gcc
$ tar xjvf /cygdrive/e/gnu/source/gcc-2.95.2a.tar.bz2
则会在src/gcc下建立子目录gcc-2.95.2a,其中包含了GCC and G++ source files
GNU Debugger with Insight Unzip
$ cd /src/gdb
$ tar xjvf /cygdrive/e/gnu/source/insight-5.1a.tar.bz2
则会在src/gdb下建立子目录insight-5.1a,其中包含了GNU Debugger with Insight source files.
- mount tmp目录,一般会不需要
$ mount –f –b c:/cygwin/tmp /tmp
-f : force mount,-b : text files are equivalent to binary files
- build the cross-development tools
$ mkdir –p /tmp/build/binutils
$ cd /tmp/build/binutils
$ /src/binutils/binutils-2.11.2a/configure –target=i386-elf /
--prefix=/tools /
--exec-prefix=/tools/H-i386-pc-cygwin /
-v 2>&1 | tee configure.out
$ make –w all install 2>&1 | tee make.out
经过上述步骤,就为Intel x86平台建立了GNU Binutils,这些文件在c:/cygwin/tools/H-i686-pc-cygwin/bin下,包含的文件如i386-elf-as.exe等。
- make sure the path is configured properly and that the binary utilities are at the head of the path.
$ PATH=/tools/H-i386-pc-cygwin/bin:$PATH; export PATH
通过“我的电脑”的属性,设定PATH环境变量包含c:/cygwin/tools/H-i386-pc-cygwin/bin;将其放在front of the path。
- verify the GNU Binutils
$ i386-elf-as –version
- Build the GNU C/C++ compile
$ mkdir –p /tmp/build/gcc
$ cd /tmp/build/gcc
$ /src/gcc/gcc-2.95.2a/configure –target=i386-elf /
--prefix=/tools /
--exec-prefix=/tools/H-i686-pc-cygwin /
--with-gnu-as –with-gnu-ld –with-newlib /
-v 2>&1 | tee configure.out
$ make –w all -gcc install –gcc /
LANGUAGES=“c c++” 2>&1 | tee make.out
通过上述步骤,GNU C/C++ compiler存在于c:/cygwin/tools/H-i686-pc-cygwin/bin下,包含的文件有i386-elf-gcc.exe等
- verify GNU C/C++ compiler
$ i386-elf-gcc –version
- build GNUDebugger with Insight
$ mkdir –p /tmp/build/gdb
$ cd /tmp/build/gdb
$ /src/gdb/insight-5.1a/configure –target=i386-elf /
--prefix=/tools /
--exec-prefix=/tools/H-i386-pc-cygwin /
-v 2>&1 | tee configure.out
$ make –w all install CC=’gcc –mwin32’ 2 >&1 | tee make.out
通过上述步骤,GNU Debugger with Insight Interface created for the Intel x86 platform.文件包含于c:/cygwin/tools/H-i386-pc-cygwin/bin下,包含的文件有i386-elf-gdb.exe等。
- verify the GNU Debugger
$ i386-elf-gdb –version
- 可以删除如下目录
c:/cygwin/src/binutils
c:/cygwin/src/gcc
c:/cygwin/src/gdb
c:/cygwin/tmp/build/binutils
c:/cygwin/tmp/build/gcc
c:/cygwin/tmp/build/gdb
至此,交叉编译环境建立。