完成交叉编译前,查看了不少资料,实践过程不是太顺利。现将成功交叉编译的过程记录如下:
首先,下载相应的包,我使用的是:zlib-1.2.5.tar.bz2、popt-1.14.tar.gz、binutils-2.23.2.tar.bz2和oprofile-0.9.6.tar.gz。前3者是oprofile编译的基础。
zlib比较简单,./configure --prefix=TARGET CC=(CROSSCOMPILE)gcc; make; make install
popt编译
ac_cv_va_copy=yes
./configure --with-kernel-support --host=mips-linux-gnu --prefix=TARGET
CC=(CROSSCOMPILE)gcc
#这个是必须做的,configure中有使用,非交叉编译不需要
#host这一项要特别注意,根据使用C库选择gnu还是uclibc
make
make install
为后续使用编译环境参数的方便,可以构造一个初始环境
vi env.sh
CROSSCOMP=交叉工具
export CC=${CROSS_COMPILE}gcc
export CPP=${CROSS_COMPILE}cpp
export CXX=${CROSS_COMPILE}g++
export CFLAGS=-static
export CXXFLAGS=-static
export CPPFLAGS=-static
./env.sh或source env.sh
binutils编译
./configure --prefix=${TARGET} --host=mips-linux-gnu --with-kernel-support --enable-shared
make configure-host
make LDFLAGS="-all-static"
make install
oprofile编译
./configure --with-kernel-support --host=mips-linux-gnu
--prefix=$PWD/oprofile/ --with-extra-libs=$PWD/popt/lib/:$PWD/zlib/lib/:$PWD/binutils/lib/ --with-extra-includes=$PWD/popt/include/ --with-binutils=/home/liujin/Fcvp/chip_brcm63168/applications/binutils
make
make install
生成工具