- 论坛徽章:
- 0
|
2.8
编译完整的glibc
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4-stage1$ cd
${SRC}
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ mkdir -p
BUILD/glibc-2.3.5
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ cd
BUILD/glibc-2.3.5
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5$ BUILD_CC=gcc
CC=${CROSS_COMPILE}gcc AR=${CROSS_COMPILE}ar RANLIB=${CROSS_COMPILE}ranlib
AS=${CROSS_COMPILE}as LD=${CROSS_COMPILE}ld ../../glibc-2.3.5/configure
--prefix=/usr --build=i386-ubuntu-linux --host=arm-unknown-linux-gnu
--target=arm-unknown-linux-gnu --without-__thread --enable-add-ons=linuxthreads
--with-headers=${SYSROOT}/usr/include
说明:
--prefix:
指定安装路径。
--target: 指定目标平台。
--host:
指定当前平台。
--build:
指定编译平台。
--with-sysroot:
用于指定编译所需要的头文件,及链接库。
--enable-add-ons:
加入其它的库,如线程库等。
--enable-languages:
指定gcc所支持的语言。
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5$
make
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5$ su
root
root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5# make
install_root=${SYSROOT} install
root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5#
exit
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5$
2.9
编译完整的gcc
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/glibc-2.3.5$ cd
${SRC}
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ mkdir -p
BUILD/gcc-3.4.4
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ cd
BUILD/gcc-3.4.4
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4$../../gcc-3.4.4/configure
--prefix=${PREFIX} --target=${TARGET} --with-sysroot=${SYSROOT} --disable-nls
--enable-threads=posix --enable-symvers=gnu --enable-__cxa_atexit
--with-softfloat-support=internal --enable-languages=c,c++ --enable-shared
--enable-c99 --enable-long-long
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4$
make
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4$ su
root
root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4# make
install
root@ubuntu:/home/arm/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4#
exit
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4$
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gcc-3.4.4$ arm-linux-gcc
-v
Reading specs from
/usr/local/arm/3.4.4/lib/gcc/arm-linux/3.4.4/specsConfigured with:
../../gcc-3.4.4/configure --prefix=/usr/local/arm/3.4.4 --target=arm-linux
--with-sysroot=/usr/local/arm/3.4.4/sysroot --disable-nls --enable-threads=posix
--enable-symvers=gnu --enable-__cxa_atexit --with-softfloat-support=internal
--enable-languages=c,c++ --enable-shared --enable-c99
--enable-long-long
Thread model: posix
gcc version
3.4.4
arm@ubuntu:/usr/local/arm/3.4.4$ tree -L 1
.
|--
arm-linux
|--
bin
|--
include
|--
info
|--
lib
|--
libexec
|--
man
|--
share
`--
sysroot
arm@ubuntu:/usr/local/arm/3.4.4$ du -sh
193M .
arm@ubuntu:/usr/local/arm/3.4.4/bin$ ls
arm-linux-addr2line
arm-linux-c++filt arm-linux-gcc-3.4.4 arm-linux-nm
arm-linux-readelf
arm-linux-ar
arm-linux-cpp arm-linux-gccbug
arm-linux-objcopy
arm-linux-size
arm-linux-as
arm-linux-g++ arm-linux-gcov
arm-linux-objdump
arm-linux-strings
arm-linux-c++
arm-linux-gcc arm-linux-ld
arm-linux-ranlib arm-linux-strip
2.10
测试gcc,g++
arm@ubuntu:~$ vi
hello_c.c
#include
#include
int
main()
{
printf("Hello,World~\n");
return
0;
}
arm@ubuntu:~$ vi
hello_cpp.cpp
#include
using
std::cout;
using
std::endl;
int
main()
{
cout
return
0;
}
arm@ubuntu:~$ arm-linux-gcc
hello_c.c -o hello_c
arm@ubuntu:~$ arm-linux-g++
-o hello_cpp hello_cpp.cpp
arm@ubuntu:~$ tree -L
1
.
|--
dev_home
|--
hello_c
|--
hello_c.c
|--
hello_cpp
`--
hello_cpp.cpp
1 directory, 4
files
arm@ubuntu:~$ file
hello_c
hello_c: ELF 32-bit LSB
executable, ARM, version 1 (ARM), for GNU/Linux 2.0.0, dynamically linked (uses shared libs),
for GNU/Linux 2.0.0, not stripped
arm@ubuntu:~$ file
hello_cpp
hello_cpp: ELF 32-bit LSB
executable, ARM, version 1 (ARM), for GNU/Linux 2.0.0, dynamically linked (uses shared libs),
for GNU/Linux 2.0.0, not stripped
2.11
编译主机上运行的gdb
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ tar zxvf
gdb-6.4.tar.gz
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ mkdir -p
BUILD/gdb-6.4-host
arm@ubuntu:~/dev_home/btools/tchain3.4.4$ cd
BUILD/gdb-6.4-host
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gdb-6.4-host$ export
CC=gcc
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gdb-6.4-host$
../../gdb-6.4/configure --target=arm-linux
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gdb-6.4-host$
make
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gdb-6.4-host$ file
gdb/gdb
gdb/gdb: ELF 32-bit LSB
executable, Intel 80386, version 1 (SYSV), for GNU/Linux 2.2.0, dynamically linked (uses shared libs),
for GNU/Linux 2.2.0, not stripped
2.12建立目标平台上运行的gdbserver
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gdb-6.4-host$ mkdir -p
../gdbserver-6.4
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gdb-6.4-host$ cd
../gdbserver-6.4
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gdbserver-6.4$ export
CC=/usr/local/arm/3.4.4/bin/arm-linux-gcc
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gdbserver-6.4$
../../gdb-6.4/gdb/gdbserver/configure
--host=arm-linux
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gdbserver-6.4$
make
arm@ubuntu:~/dev_home/btools/tchain3.4.4/BUILD/gdbserver-6.4$ file gdbserver
gdbserver: ELF 32-bit LSB
executable, ARM, version 1 (ARM), for GNU/Linux 2.0.0, dynamically linked (uses shared libs),
for GNU/Linux 2.0.0, not stripped
3
GNU交叉工具链的下载
工具链的官方下载地址:
[color="#0000ff"]http://www.arm.linux.org.uk/
可以从该站点下载2.95.3, 3.0以及3.2工具链
[color="#0000ff"]ftp://ftp.arm.linux.org.uk/pub/armlinux/toolchain/cross-2.95.3.tar.bz2
[color="#0000ff"]ftp://ftp.arm.linux.org.uk/pub/armlinux/toolchain/cross-3.0.tar.bz2
ftp://ftp.handhelds.org/projects/toolchain/arm-linux-gcc-3.3.2.tar.bz2
ftp://ftp.handhelds.org/projects/toolchain/arm-linux-gcc-3.4.1.tar.bz2
http://ftp.snapgear.org/pub/snapgear/tools/arm-linux/gcc-3.4.4.tar.bz2
本文来自ChinaUnix博客,如果查看原文请点:http://blog.chinaunix.net/u/27691/showart_373893.html |
|