hostapd、wpa_supplicant 交叉編譯

Li-Yongjun 2021-09-18 06:01:27 阅读数:442

hostapd wpa_supplicant wpa supplicant 交叉

簡介

hostapd
    AP 側進程,可以構建一個獨立 AP 或者一個 RADIUS 認證服務器

wpa_supplicant
    STA 側進程,包含了 802.1x、WPA 的請求工作

wpad
    = hostapd + wpa_supplicant,使用:wpad [hostapd | wpa_supplicant] [arguments]

hostapd and wpa_supplicant

編譯所需源碼文件

hostapd$ tree
.
├── hostapd-2.9.tar.gz
├── libnl-3.2.25.tar.gz
├── openssl-1.1.1a.tar.gz
└── wpa_supplicant-2.9.tar.gz

下載鏈接

依賴

hostapd 和 wpa_supplicant 均依賴 libnl 和 openssl

所以先編譯 libnl 和 openssl,再編譯 hostapd 和 wpa_supplicant。

libnl

$ tar -xvf libnl-3.2.25.tar.gz
$ cd libnl-3.2.25/
$ mkdir _install
$ ./configure CC=arm-linux-gnueabihf-gcc --prefix=$(pwd)/_install --host=arm-linux-gnueabihf
$ make
$ make install

openssl

$ tar -xvf openssl-1.1.1a
$ cd openssl-1.1.1a/
$ ./config no-asm shared --prefix=$(pwd)/__install

$ vim Makefile

-CROSS_COMPILE=
+CROSS_COMPILE=arm-linux-gnueabihf-
-CNF_CFLAGS=-pthread -m64
+CNF_CFLAGS=-pthread
$ make
$ make install

hostapd

$ tar -xvf hostapd-2.9.tar.gz
$ cd hostapd-2.9/hostapd
$ cp defconfig .config

$ vim .config

CONFIG_LIBNL32=y
+CFLAGS += -I /home/liyongjun/project/c/ARM/hostapd/libnl-3.2.25/_install/include/libnl3
+LIBS += -L /home/liyongjun/project/c/ARM/hostapd/libnl-3.2.25/_install/lib
+CFLAGS += -I /home/liyongjun/project/c/ARM/hostapd/openssl-1.1.1a/_install/include
+LIBS += -L /home/liyongjun/project/c/ARM/hostapd/openssl-1.1.1a/_install/lib

$ vim Makefile

+CC=arm-linux-gnueabihf-gcc
ifndef CC
CC=gcc
endif
$ make
Package libnl-3.0 was not found in the pkg-config search path.
Perhaps you should add the directory containing `libnl-3.0.pc' to the PKG_CONFIG_PATH environment variable No package 'libnl-3.0' found

報錯,提示通過 pkg-config 沒有搜索到 libnl-3.0 庫,需要通過 PKG_CONFIG_PATH 環境變量指明 libnl-3.0.pc 所在的目錄,以至於能够找到 libnl-3.0 庫。

我們可以手動執行命令 pkg-config --list-all,可以看到列錶中確實沒有 libnl-3.0 庫,因為在前面步驟中,我們是把 libnl-3.0 庫安裝在源碼所在目錄的,並且我們是交叉編譯,編譯出來的庫也都是 ARM 架構的,也不應該安裝到宿主機的默認動態庫目錄中。

解决辦法:

$ export PKG_CONFIG_PATH=/home/liyongjun/project/c/ARM/hostapd/libnl-3.2.25/_install/lib/pkgconfig/
$ make

wpa_supplicant

$ tar -xvf wpa_supplicant-2.9.tar.gz
$ cd wpa_supplicant-2.9/wpa_supplicant/
$ cp defconfig .config

$ vim .config

CONFIG_LIBNL32=y
+CFLAGS += -I /home/liyongjun/project/c/ARM/hostapd/libnl-3.2.25/_install/include/libnl3
+LIBS += -L /home/liyongjun/project/c/ARM/hostapd/libnl-3.2.25/_install/lib
+CFLAGS += -I /home/liyongjun/project/c/ARM/hostapd/openssl-1.1.1a/_install/include
+LIBS += -L /home/liyongjun/project/c/ARM/hostapd/openssl-1.1.1a/_install/lib

$ vim Makefile

+CC=arm-linux-gnueabihf-gcc
ifndef CC
CC=gcc
endif
$ make
...
dbus/dbus_dict_helpers.c:10:10: fatal error: dbus/dbus.h: 沒有那個文件或目錄
10 | #include <dbus/dbus.h>
| ^~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:1991:dbus/dbus_dict_helpers.o] 錯誤 1

報錯,提示找不到 dbus/dbus.h 文件
解决辦法,我們不需要 dbus 功能,所以直接關閉該功能
vim .config

# Add support for new DBus control interface
# (fi.w1.hostap.wpa_supplicant1)
-CONFIG_CTRL_IFACE_DBUS_NEW=y
+#CONFIG_CTRL_IFACE_DBUS_NEW=y
# Add introspection support for new DBus control interface
-CONFIG_CTRL_IFACE_DBUS_INTRO=y
+#CONFIG_CTRL_IFACE_DBUS_INTRO=y
make

over

版权声明:本文为[Li-Yongjun]所创,转载请带上原文链接,感谢。 https://gsmany.com/2021/09/20210918060126507w.html