How to cross compile the PPP to arm-xscale

1.

如果需要让pppd支持packet filtering 功能的话就需要编译libpcap.

cross compile libpcap-1.0.0


./configure --host=arm-xscale-linux-gnu --prefix=/usr/arm-xscale-linux-gnu/

直接出错了

configure: error: pcap type not determined when cross-compiling; use --with-pcap=...

 

比较了非交叉编译的log,发现需要加上--with-pcap=linux

./configure --host=arm-xscale-linux-gnu --prefix=/usr/arm-xscale-linux-gnu/ --with-pcap=linux

checking Linux kernel version... unknown
configure: error: cannot determine linux version when cross-compiling

 

查configure文件if test $ac_cv_linux_vers = unknown ; then
                { { echo "$as_me:$LINENO: error: cannot determine linux version when cross-compiling" >&5
echo "$as_me: error: cannot determine linux version when cross-compiling" >&2;}
   { (exit 1); exit 1; }; }

 

原来是交叉编译器无法通过uname获得arm linux 的版本.只能通过cache文件设置了.


echo ac_cv_linux_vers=linux-2.6.15.6-xyz4>arm-linux.cache
./configure --cache-file=arm-linux.cache --host=arm-xscale-linux-gnu --prefix=/usr/arm-xscale-linux-gnu/ --with-pcap=linux
make
make install

这下过了libpcap-1.0.0被安装到了/usr/arm-xscale-linux-gnu/ 目录下

 

2.

cross compile ppp-2.4.4
./configure --prefix=/usr/arm-xscale-linux-gnu   <--  ppp-2.4.4 只支持--prefix/--sysconf参数,其他都不支持

 

make CC=/opt/gcc-4.1.2-glibc-2.4/arm-xscale-linux-gnu/bin/arm-xscale-linux-gnu-gcc

options.c:59:18: error: pcap.h: No such file or directory
options.c: In function 'process_option':
options.c:781: warning: dereferencing type-punned pointer will break strict-aliasing rules
options.c: In function 'setpassfilter':
options.c:1458: error: 'pcap_t' undeclared (first use in this function)
options.c:1458: error: (Each undeclared identifier is reported only once
options.c:1458: error: for each function it appears in.)
options.c:1458: error: 'pc' undeclared (first use in this function)

 

个人觉得,ppp的Makefile 有问题,没有在configure的时候把 --prefix 所指向的路径作为默认路径.

我的做法有两种
第一种在  pppd/Makefile 文件中

line86 行 CFLAGS= $(COPTS) $(COMPILE_FLAGS) $(INCLUDE_DIRS) '-DDESTDIR="/usr/arm-xscale-linux-gnu"'
后添加
CFLAGS += -I$(DESTDIR)/include

LDFLAGS = -L$(DESTDIR)/lib


或者
第二种也是在 pppd/Makefile 文件中

直接disable PPP packet filtering,这样的话libpcap-1.0.0甚至都不用编译

# Uncomment the next line to include support for PPP packet filtering.
# This requires that the libpcap library and headers be installed
# and that the kernel driver support PPP packet filtering.
#FILTER=y

 

两种任一种改完,再运行
make CC=/opt/gcc-4.1.2-glibc-2.4/arm-xscale-linux-gnu/bin/arm-xscale-linux-gnu-gcc
make install

ppp的包就被安装在pc的/usr/arm-xscale-linux-gnu/, 把该目录原封不动拷贝到板子的相同路径下,就可以在板子上运行pppd了.

 

OK.

你可能感兴趣的:(How to cross compile the PPP to arm-xscale)