Hostapd的移植,依賴:libnl openssl linux
下載地址:redis
Hostapd-2.6:http://w1.fi/releases/hostapd-2.6.tar.gzshell
Libnl: http://www.infradead.org/~tgr/libnl/files/vim
Openssl: https://www.openssl.org/source/old/1.0.1/app
Libnl: 交叉編譯 (選擇的版本是libnl-1.1.tar.gz)async
解壓安裝包,建一個__install文件夾用來保存安裝的庫文件spa
# mkdir __install.net
#./configure CC=arm-fullhan-linux-uclibcgnueabi-gcc --prefix=$PWD/__install --host=arm3d
#make & make installcode
能夠看到__install/lib/ 下面有生成的libnl動態庫
若是但願能生成靜態庫,對lib/Makefile作以下修改:
#vim lib/Makefile
修改好的 lib/Makefile
1 # 2 # lib/Makefile 3 # 4 # This library is free software; you can redistribute it and/or 5 # modify it under the terms of the GNU Lesser General Public 6 # License as published by the Free Software Foundation version 2.1 7 # of the License. 8 # 9 # Copyright (c) 2003-2006 Thomas Graf <tgraf@suug.ch> 10 # 11 12 ifeq ($(shell [ ! -r ../Makefile.opts ] && echo 1),) 13 include ../Makefile.opts 14 endif 15 16 # Core 17 CIN := $(wildcard *.c) 18 # NETLINK_ROUTE 19 CIN += $(wildcard route/*.c) 20 # Schedulers 21 CIN += $(wildcard route/sch/*.c) 22 # Classifiers 23 CIN += $(wildcard route/cls/*.c) 24 # Link Info Modules 25 CIN += $(wildcard route/link/*.c) 26 # NETLINK_GENERIC 27 CIN += $(wildcard genl/*.c) 28 # fib lookup 29 CIN += $(wildcard fib_lookup/*.c) 30 # Netfilter 31 CIN += $(wildcard netfilter/*.c) 32 33 DEPS := $(CIN:%.c=%.d) 34 OBJ := $(CIN:%.c=%.o) 35 CFLAGS += -fPIC 36 OUT_LIB := $(PACKAGE_NAME).a 37 OUT_SLIB := $(PACKAGE_NAME).so.$(PACKAGE_VERSION) 38 LN_SLIB := $(PACKAGE_NAME).so 39 LN1_SLIB := $(LN_SLIB).1 40 41 export 42 43 .PHONY: all clean install librtn.a $(OUT_SLIB) 44 45 46 all: 47 @echo " MAKE $(OUT_LIB)"; \ 48 $(MAKE) $(OUT_LIB) 49 @echo " MAKE $(OUT_SLIB)"; \ 50 $(MAKE) $(OUT_SLIB) 51 52 $(OUT_LIB): ../Makefile.opts $(OBJ) 53 @echo " LD $(OUT_LIB)"; \ 54 echo $(AR) rs $(OUT_LIB) $(OBJ) 55 $(AR) rs $(OUT_LIB) $(OBJ) 56 57 $(OUT_SLIB): ../Makefile.opts $(OBJ) 58 @echo " LD $(OUT_SLIB)"; \ 59 $(CC) -shared -Wl,-soname,libnl.so.1 -o $(OUT_SLIB) $(OBJ) $(LIBNL_LIB) -lc 60 @echo " LN $(OUT_SLIB) $(LN1_SLIB)"; \ 61 rm -f $(LN1_SLIB) ; $(LN) -s $(OUT_SLIB) $(LN1_SLIB) 62 @echo " LN $(LN1_SLIB) $(LN_SLIB)"; \ 63 rm -f $(LN_SLIB) ; $(LN) -s $(LN1_SLIB) $(LN_SLIB) 64 65 clean: 66 @echo " CLEAN lib"; \ 67 $(RM) -f $(OBJ) $(OUT_LIB) $(OUT_SLIB) $(LN_SLIB) $(LN1_SLIB); \ 68 $(RM) -f $(DEPS) $(OUT_LIB) $(OUT_SLIB) $(LN_SLIB) $(LN1_SLIB) 69 70 distclean: 71 @echo " DISTCLEAN lib"; \ 72 $(RM) -f $(DEPS) 73 74 install: 75 mkdir -p $(DESTDIR)$(libdir)/ 76 install -m 0644 $(OUT_SLIB) $(DESTDIR)$(libdir) 77 install -m 0644 $(OUT_LIB) $(DESTDIR)$(libdir) 78 rm -f $(DESTDIR)$(libdir)/$(LN1_SLIB) 79 $(LN) -s $(OUT_SLIB) $(DESTDIR)$(libdir)/$(LN1_SLIB) 80 rm -f $(DESTDIR)$(libdir)/$(LN_SLIB) 81 $(LN) -s $(LN1_SLIB) $(DESTDIR)$(libdir)/$(LN_SLIB) 82 83 $(DEPS): ../Makefile.opts 84 85 include ../Makefile.rules
保存退出,make& make install 就能夠生成libnl.a 靜態庫了。
Openssl交叉編譯:(選擇的版本是openssl-1.1.1.tar.gz)
解壓安裝包,建一個__install文件夾用來保存安裝的庫文件
# mkdir __install
# ./config no-asm no-shared no-async --prefix=$PWD/__install
注意:若是不加入no-async,會出現如下錯誤:
./libcrypto.a(b_sock.o): In function `BIO_gethostbyname':
b_sock.c:(.text+0x4a8): warning: gethostbyname is obsolescent, use getnameinfo() instead.
./libcrypto.a(async_posix.o): In function `ASYNC_is_capable':
async_posix.c:(.text+0x48): undefined reference to `getcontext'
./libcrypto.a(async_posix.o): In function `async_fibre_makecontext':
async_posix.c:(.text+0x7c): undefined reference to `getcontext'
async_posix.c:(.text+0xec): undefined reference to `makecontext'
./libcrypto.a(async.o): In function `async_fibre_swapcontext':
async.c:(.text+0x28c): undefined reference to `setcontext'
collect2: ld returned 1 exit status
make[1]: *** [apps/openssl] Error 1
make[1]: Leaving directory `/test/hostapd_test/openssl-1.1.1'
make: *** [all] Error 2
修改Makefile
#PLATFORM=linux-x86
PLATFORM=linux-armv7
#CROSS_COMPILE
CROSS_COMPILE=arm-fullhan-linux-uclibcgnueabi-
刪除全部的 -m32 -m64選項
保存退出,make clean
Make & make install
在__install 裏面就能夠看到靜態庫了:
Hostapd的編譯:(選擇的版本是hostapd-2.6.tar.gz)
解壓hostapd-2.6安裝包,進入
# cp defconfig .config
修改Makefile
CC=arm-fullhan-linux-uclibcgnueabi-gcc
CFLAGS += -I /test/hostapd_test/libnl-1.1/__install/include
LIBS += -L /test/hostapd_test/libnl-1.1/__install/lib -lnl
CFLAGS += -I /test/hostapd_test/openssl-1.1.1/__install/include
LIBS += -L /test/hostapd_test/openssl-1.1.1/__install/lib -lcrypto -lssl
BINDIR := ./__install/bin
LDFLAGS += -lpthread
LDFLAGS += -lm
注意:
Libnl 和 libopenssl 爲上述步驟編譯生成的。此處的包含路徑能夠選擇絕對路徑。
若是不加入LDFLAGS += -lpthread ,LDFLAGS += -lm 兩個選項會出現以下錯誤:
install/lib/libnl-1.1.a(utils.o): In function `nl_prob2int':
libnl-1.1.1/lib/utils.c:392: undefined reference to `rint'
collect2: ld returned 1 exit status
保存;
#make & make install
就能夠在__install/bin 下面生成hostapd命令了。
注意:由於libnl和libopenssl都是編譯成靜態庫形式,因此hostapd在開發板上能夠直接運行,不須要將libxxx.so 拷貝到/lib/下面。
參考:http://www.javashuo.com/article/p-gnxachdr-na.html
WiFi模塊常常用到hostapd啓軟AP,換個平臺,又得從新編譯一遍,因此本身整理下,下次找也方便。借鑑了上述文章,還請不吝賜教,若侵權,聯繫即刪。