Compilation environment: Ubuntu16.04 64-bit
Cross-compilation tool: arm-ca9-linux-uclibcgnueabihf-gcc
Article directory
1. Cross compile libnl
The cross-compilation of wpa_supplicant depends on libnl and openssl. Here we cross-compile libnl first. I am using libnl-1.1.4.tar.gz here, click on the download address .
tar zxf libnl-1.1.4.tar.gz
cd libnl-1.1.4/
./configure --prefix=/root/wifi/wifiLib/libnl --host=arm-ca9-linux-uclibcgnueabihf --enable-static --enable-shared CC=arm-ca9-linux-uclibcgnueabihf-gcc CFLAGS="-march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard -ftree-vectorize -fno-builtin -fno-common -Wformat=1"
make
make install
The libnl.a and libnl.so.1.1.4 generated in the /root/wifi/wifiLib/libnl/lib/ directory are the libraries needed to compile wpa_supplicant later. The libnl.a and libnl.so.1.1.4 generated in the /root/wifi/wifiLib/libnl/include/ directory are is the header file.
2. Cross compile openssl
Openssl has been compiled before being transplanted and used in openssh , so it will be recompiled here. What I use here is openssl-1.1.0g.tar.gz, click on the download address .
tar zxf openssl-1.1.0g.tar.gz
cd openssl-1.1.0g/
./Configure linux-armv4 --cross-compile-prefix=arm-ca9-linux-uclibcgnueabihf- --prefix=/root/wifi/wifiLib/openssl shared no-autoerrinit no-idea no-camellia no-seed no-bf no-cast no-engine no-hw no-cms no-capieng no-comp no-zlib no-zlib-dynamic no-async threads no-ts no-ui no-asm
Modify the Makefile and add the following content:
CFLAGS += -march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard -ftree-vectorize -fno-builtin -fno-common -Wformat=1
Execute compilation
make
make install
The libcrypto.a and libssl.a generated in the /root/wifi/wifiLib/openssl/lib directory and the corresponding dynamic libraries are the libraries needed to compile wpa_supplicant later. The header files are located in /root/wifi/wifiLib/openssl/include/.
3. Cross compile wpa_supplicant
What I use here is wpa_supplicant-2.6.tar.gz, click on the download address .
3. 1 Unzip
tar zxf wpa_supplicant-2.6.tar.gz
cd wpa_supplicant-2.6/wpa_supplicant
cp defconfig .config
3. 2 Modify config
Add the following content at the end of the .config file:
CFLAGS += -I/root/wifi/wifiLib/libnl/include
LIBS += -L/root/wifi/wifiLib/libnl/lib
CFLAGS += -I/root/wifi/wifiLib/openssl/include
LIBS += -L/root/wifi/wifiLib/openssl/lib
CFLAGS += -O3 -fPIC -march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard -ftree-vectorize -fno-builtin -fno-common -Wformat=1
CC=arm-ca9-linux-uclibcgnueabihf-gcc -L/root/wifi/wifiLib/openssl/lib
3. 3 Modify Makefile
BINALL=wpa_supplicant wpa_cli libwpa_client.a
3. 4 Compilation
make
arm-ca9-linux-uclibcgnueabihf-strip wpa_supplicant
arm-ca9-linux-uclibcgnueabihf-strip wpa_cli
After successful compilation, wpa_supplicant and wpa_cli are located in the current directory, and libwpa_client.a is the required static library.
4. Cross-compile hostapd
I am using hostapd-2.6.tar.gz here, click on the download address .
4. 1 Unzip
tar zxf hostapd-2.6.tar.gz
cd hostapd-2.6/hostapd
cp defconfig .config
4. 2 Modify config
Add the following content at the end of the .config file:
CFLAGS += -I/root/wifi/wifiLib/libnl/include
LIBS += -L/root/wifi/wifiLib/libnl/lib
CFLAGS += -I/root/wifi/wifiLib/openssl/include
LIBS += -L/root/wifi/wifiLib/openssl/lib
CFLAGS += -O3 -fPIC -march=armv7-a -mtune=cortex-a9 -mfpu=neon -mfloat-abi=hard -ftree-vectorize -fno-builtin -fno-common -Wformat=1
CC=arm-ca9-linux-uclibcgnueabihf-gcc -L/root/wifi/wifiLib/openssl/lib
4.3 Compilation
make
arm-ca9-linux-uclibcgnueabihf-strip hostapd
After successful compilation, hostapd is located in the current directory.