本文依据目前工作场景中需要使用到交叉编译的第三方库的方法罗列至此,后续持续更新。
(一)binutils-2.27
https://mirrors.nju.edu.cn/gnu/binutils/
./configure --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc --prefix=$(pwd)/__install
make -j4 && make install
(二)coreutils-8.32
https://mirrors.nju.edu.cn/gnu/coreutils/
git clone https://git.savannah.gnu.org/git/coreutils.git
apt-get install autopoint
apt-get install gettext(coreutils-8.27)
apt-get install texinfo(texinfo-6.5)
apt-get install libssl-dev
--修改Makefile "gcc cc1: all warnings being treated as errors"
WERROR_CFLAGS = -Werror
替换为
WERROR_CFLAGS = -Wno-error
--编译 make-prime-list
echo "export set FORCE_UNSAFE_CONFIGURE=1" >> /etc/profile
source /etc/profile
./configure --disable-year2038 && make
--配置交叉编译环境
make clean && ./configure --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc --prefix=$(pwd)/__install --disable-year2038 && make -j4 && make install
(三)ncurses-6.2
https://mirrors.nju.edu.cn/gnu/ncurses/
./configure --prefix=$(pwd)/__install --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf CXX=arm-linux-gnueabihf-g++ CC=arm-linux-gnueabihf-gcc --with-shared --with-normal
make -j4 && make install
(四)procps-v3.3.17
注:top指令需要关联ncurses 才可以编译生成,其编译选项需添加ncurses头文件与库地址。
https://gitlab.com/procps-ng/procps
./autogen.sh
echo "ac_cv_func_realloc_0_nonnull=yes" > arm-linux.cache
echo "ac_cv_func_malloc_0_nonnull=yes" >> arm-linux.cache
#./configure --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc -prefix=$(pwd)/__install --without-ncurses --cache-file=arm-linux.cache
./configure --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc CFLAGS="-I /3rdparty/ncurses-6.2/__install/include/ -I /3rdparty/ncurses-6.2/__install/include/ncurses" NCURSES_LIBS="-L/3rdparty/ncurses-6.2/__install/lib -lncurses" --prefix=$(pwd)/__install --with-ncurses --cache-file=arm-linux.cache
make -j4 && make install
(五)grep-3.11
https://mirrors.nju.edu.cn/gnu/grep/
./configure --prefix=$(pwd)/__install --host=arm-linux-gnueabihf --target=arm-linux-gnueabihf CXX=arm-linux-gnueabihf-g++ CC=arm-linux-gnueabihf-gcc
make -j4 && make install
(六)gdb7.12.1
https://mirrors.nju.edu.cn/gnu/gdb/
./configure --host=arm-linux-gnueabihf --enable-shared --prefix=$PWD/__install --without-x --disable-gdbtk --disable-tui --without-included-regex --without-included-gettext
make -j4 && make install
(七)valgrind-3.16.1
注:板载运行环境应与PC端编译路径一致
#修改configure 把armv7a* 改为 arm*
./configure --host=arm-linux-gnueabihf CC=arm-linux-gnueabihf-gcc --prefix= --prefix=$PWD/__install
make -j4 && make install
(八)dmalloc-5.6.5
https://dmalloc.com/releases/
./configure --prefix=$PWD/__install --host=arm-linux-gnueabihf
---编译提示问题:
dmalloc.h:377:7: error: expected identifier or ‘(’ before ‘__extension__’
char *strdup(const char *string);
dmalloc.h:396:7: error: expected identifier or ‘(’ before ‘__extension__’
char *strndup(const char *string, const DMALLOC_SIZE max_len);
----问题解决:
在dmalloc.h:377内容前添加: #undef strdup
在dmalloc.h:396内容前添加: #undef strndup
make -j4 && make install
(九)libev-4.33
http://dist.schmorp.de/libev/
./configure --prefix=$PWD/__install --host=arm-linux-gnueabihf
make -j4;make install
(十)libpcap-1.7.4
https://github.com/the-tcpdump-group/libpcap/tags
如果遇到报错:configure: error: Neither flex nor lex was found.
解决方法:sudo apt-get install flex bison
./configure --prefix=$PWD/__install --host=arm-linux-gnueabihf --with-pcap=linux
make && make install
(十一)libpcap-1.7.4
https://github.com/the-tcpdump-group/tcpdump/tags
依赖于libcap环境
./configure --prefix=$PWD/__install --host=arm-linux-gnueabihf CFLAGS="-I/home/wow/3rdparty/libpcap-libpcap-1.7.4/__install/include/" LDFLAGS="-L/home/wow/3rdparty/libpcap-libpcap-1.7.4/__install/lib/"
make && make install