打开APP
userphoto
未登录

开通VIP,畅享免费电子书等14项超值服

开通VIP
交叉编译 hostapd

1,  Try building hostapd

    1)Download hostapd-2.0.tar.gz
    tar xzvf hostapd-2.0.tar.gz
    cd hostapd-2.0/hostapd
 cp defconfig .config
 Modify .config, let
        CONFIG_DRIVER_NL80211=y
    modify Makefile
    CC= XX-linux-gcc
    CFLAGS += -mle -march=xx


 2) make;
 error info output, it shows hostapd depends on libnl library.
 ../src/drivers/driver_nl80211.c:25:31: fatal error: netlink/genl/genl.h: No such file or directory
 
 3) to check if it depends on other library:
 let CONFIG_DRIVER_NL80211=n in .config
 make;
 another error info output as befow, it shows hostapd also depends on openssl library,
 ../src/crypto/tls_openssl.c:23:25: fatal error: openssl/ssl.h: No such file or directory
compilation terminated.

    the openssl library has be make and installed before, in /home/libinsall/openssl
 add it to .config as below:
  31 CFLAGS+= -march=xx -mle -Os -I/home/install/openssl/include
     32 LDFLAGS += -ldl -march=xx -mle -I/home/install/openssl/include
     33 LIBS += -L/home/install/openssl/lib
     34 LIBS_p += -L/home/install/openssl/lib
 make again, no error output again, hostapd is output in current folder,but nl80211 driver is disabled.

 to enable nl80211 driver, CONFIG_DRIVER_NL80211 should be set y in .config,
 so the next step is to make and install libnl.
 


2, build libnl-1.1
 Somebody said hostapd use the libnl-1.1, the API of libnl with higher version has been changed and is not
 usable for hostapd, so I download libnl-1.1.tar.gz
 
 1) tar xzvf libnl-1.1.tar.gz
   cd libnl-1.1
  ./configure --prefix=/home/install/libnl
  modify Makefie.opts:
    CC=xx-linux-gcc
    AR=xx-linux-ar
    CFLAGS += -mle -march=xx


 2) make; error info output as below:
  ../include/netlink-local.h:218: error: ‘ULONG_MAX’ undeclared (first use in this function) 
     to fix this error, just add #include <limits.h> in netlink-local.h


 3) make again, other error infor output as below, it shows error output when create libnl.so.1.1
  CC netfilter/log.c
  CC netfilter/log_obj.c
  CC netfilter/nfnl.c
  LD libnl.so.1.1
  /opt/xx-glibc-le-nor31/bin/../xx-linux/sys-root/usr/lib/libm.so: could not read symbols: File in wrong format
  collect2: ld returned 1 exit status
  make[2]: *** [libnl.so.1.1] Error 1
  make[1]: *** [all] Error 2
  make: *** [all] Error 2


    4) find out the place where libnl.so.1.1 is created, it is in lib/Makefile Line 51(LIBNL_LIB = -lm):
  49 $(OUT_SLIB): ../Makefile.opts $(OBJ)
  50     @echo "  LD $(OUT_SLIB)"; \
  51     $(CC) -shared -W1,-soname,libnl.so.1 -o $(OUT_SLIB) $(OBJ) $(LIBNL_LIB) -lc
  52     @echo "  LN $(OUT_SLIB) $(LN1_SLIB)"; \
  53     rm -f $(LN1_SLIB) ; $(LN) -s $(OUT_SLIB) $(LN1_SLIB)
  54     @echo "  LN $(LN1_SLIB) $(LN_SLIB)"; \
  55     rm -f $(LN_SLIB) ; $(LN) -s $(LN1_SLIB) $(LN_SLIB)
 
  I find there is no CFLAGS option in line 51, because we are building libnl for specific SOC chip, it need specific
  compiling options "-mle -march=xx". without this option, xx-linux-gcc doesnot recognize the libm.so .
  so modify line 51 as below:
  51     $(CC) -shared -W1,-soname,libnl.so.1 -o $(OUT_SLIB) $(CFLAGS) $(OBJ) $(LIBNL_LIB) -lc


 5) make again, now libnl.so.1.1 is successfully built out. but other errors come up:
LN libnl.so.1 libnl.so
Entering include
Entering doc
Entering src
  CC utils.c
  LD nl-addr-add
/opt/ba-glibc-le-nor31/bin/../lib/gcc/ba-linux/4.5.2/../../../../ba-linux/bin/ld: warning: libm.so.6, needed by ../lib/libnl.so, not found (try using -rpath or -rpath-link)
../lib/libnl.so: undefined reference to http://blog.csdn.net/junllee/article/details/mailto:%60lrint@GLIBC_2.1'
collect2: ld returned 1 exit status
make[1]: *** [nl-addr-add] Error 1
make: *** [all] Error 2

 

    6) find out where nl-addr-add is created, it is src/Makefile:
 
 20 all: $(TOOLS)
 21
 22 $(TOOLS): utils.o
 23
 24 nl-%: nl-%.c
 25     @echo "  LD $@"; \
 26     $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
 27
 28 genl-%: genl-%.c
 29     @echo "  LD $@"; \
 30     $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
 31
 32
 33 nf-%: nf-%.c
 34     @echo "  LD $@"; \
 35     $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS)
     
   modify line 26/30/35 as below, add $(LIBNL_LIB)

 26     $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LIBNL_LIB)
 30     $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LIBNL_LIB)
 35     $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LIBNL_LIB)
 
     modify tests/Makeifle line 26, alo add $(LIBNL_LIB) as below:
 24 test-%: test-%.c
 25     @echo "  LD $@"; \
 26     $(CC) $(CFLAGS) -o $@ $< $(LDFLAGS) $(LIBNL_LIB)


     7) make;make install, successfully!!
  libnl-1.1 installed in /home/install/libnl directory.
 


3,  Come back to build hostapd


    1) add libnl library info in .config as below:
 35 CFLAGS += -I/home/joe/joeinstall/libnl/include
 36 LDFLAGS += -I/home/joe/joeinstall/libnl/include
 37 LIBS += -L/home/joe/joeinstall/libnl/lib
 38 LIBS_p += -L/home/joe/joeinstall/libnl/lib


    2) make clean;make
 error info output:
  CC  ../src/drivers/driver_common.c
/opt/ba-glibc-le-nor31/bin/../lib/gcc/ba-linux/4.5.2/../../../../ba-linux/bin/ld: warning: libm.so.6, needed by /home/joe/joeinstall/libnl/lib/libnl.so, not found (try using -rpath or -rpath-link)
/home/joe/joeinstall/libnl/lib/libnl.so: undefined reference to http://blog.csdn.net/junllee/article/details/mailto:%60lrint@GLIBC_2.1'
collect2: ld returned 1 exit status
make: *** [hostapd] Error 1


    3) modify .config, add -lm option in LDFLAGS:
32 LDFLAGS += -ldl -march=ba2 -mle -lm -I/home/joe/joeinstall/openssl/include


    4) make; ok,Done:
  CC  ../src/drivers/driver_common.c
  LD  hostapd
  CC  hostapd_cli.c
  CC  ../src/common/wpa_ctrl.c
  CC  ../src/utils/edit_simple.c
  LD  hostapd_cli

本站仅提供存储服务,所有内容均由用户发布,如发现有害或侵权内容,请点击举报
打开APP,阅读全文并永久保存 查看更多类似文章
猜你喜欢
类似文章
【热】打开小程序,算一算2024你的财运
KBUILD系统原理分析--MAKE原理介绍
Linux内核Makefile文件
KBUILD系统原理分析
hostapd实现WIFI 热点(AP)
无root权限编译R语言,或许只是一个体力活
怎样编写Makefile文件 - Moose W. Oler的日志 - 网易博客
更多类似文章 >>
生活服务
热点新闻
分享 收藏 导长图 关注 下载文章
绑定账号成功
后续可登录账号畅享VIP特权!
如果VIP功能使用有故障,
可点击这里联系客服!

联系客服