wpa_supplicant build/compile on Ubuntu

By | December 28, 2016

When you are studying IEEE802.11, Wi-Fi on linux, you often need to look at the wpa_supplicant code.

To study wpa_supplicant, you have to insert log into wpa_supplicant code, change the contents of the code, and try a lot. To do this, you must ensure that your code is working properly when you build the base code.

Therefore, we want to confirm the operation by building wpa_supplicant in Ubuntu with basic code state.


Ubuntu 14.04.5 LTS
wpa_supplicant v2.1


I have described the trial and error I went through, so the amount can be quite large. If you want to identify only the essential parts, check out the last part of this article. By default, root privileges are required.


Step 1. First, download the source code based on wpa_supplicant installed in ubuntu.

# apt-get source wpasupplicant

-. Ubuntu patches automatically applied to the code.

You can see that the wpa-2.1 directory is created just below the directory where the command is executed.


Step 2. Enter wpa-2.1/wpa_supplicant and run ‘make’ for code build.

# cd wpa-2.1/wpa_supplicant
# make

-. Since downloaded wpa-2.1 is the source code for building both hostapd and wpa_supplicant, you should go to the wpa-2.1/wpa_supplicant directory for wpa_supplicant.

However, “make” will generate an error. This is because there is no CONFIG information for the build of wpa_supplicant. In fact, this is the most difficult part. I’d like to get CONFIG information like the kernel’s .config, but I could not know that information. So first I applied defconfig, which is the default setting, and I tried to configure it as much as possible by adding it one by one.


Step 3. Copy defconfig to .config and “make” it again.

# cp defconfig .config

However, I get an error saying that the openssl/ssl.h file can not be found. You need to install the libssh-dev package.


Step 4. Install libssl-dev package and “make” again.

# apt-get install libssl-dev

But this time, I get an error saying that netlink/genl/genl.h can not be found. You need to install the ‘libnl-3-dev’ package and modify the .config file.


Step 4. Install the libnl-3-dev package, modify the .config configuration and make it again.

# apt-get install libnl-3-dev
# vi .config
# make

Open the .config configuration file and uncomment CONFIG _LIBNL32 = y and add CFLAGS + = -I/usr/include/libnl3.

However, if you do make, you will get an error saying that nl-genl-3 library can not be found. You need to install the libnl-genl-3-dev package.


Step 5. Install the libnl-genl-3-dev package and “make” it again.

# apt-get install libnl-genl-3-dev
# make

This time, “make” is completed successfully.

If you do “ls”, you can see that wpa_supplicant is created as below.


Step 6. Now replace the generated wpa_supplicant with the existing wpa_supplicant

-. Current wpa_supplicant exists in /sbin/. Before applying new wpa_supplicant, copy old wpa_supplicant to wpa_supplicant.bk and replace  old wpa_supplicant with newly built wpa_supplicant.

# cd /sbin/
# cp wpa_supplicant wpa_supplicant.bk
# cp ~/wpa-2.1/wpa_supplicant/wpa_supplicant /sbin/

If it was not built-in Wi-Fi, it would not have been a problem to replace wpa_supplicant, but if the built-in Wi-Fi was in operation, In this case, stop the network-manager, replace the wpa_supplicant file, and run the network-manager again.

# service network-manager stop
and replace wpa_supplicant
# service network-manager start

Now I plugged in a wireless Wi-Fi Lan card and checked the Wi-Fi operation.

wpa_supplicant will timeout as shown below.

Failed to activate service ‘fi.w1.wpa_supplicant1’: timed out

This time, you need to add some CONFIG to .config.


Step 7. Add some new CONFIG to your .config and make it again.





The fundamental problem that wpa_supplicant does not work is caused by the interface with the network-manager who execute wpa_supplicant. Dbus is used as an interface, but .config in wpa_supplicant are not declared by default. So you have to add dbus related CONFIG, which is metioned as “mandatory” above. The CONFIGs added as optional are added to support the same options of wpa_supplicant installed in ubuntu.

If you do “make”, this time you will get an error that dbus/dbus.h does not exist. You must install the libdbus-1-dev package.


Step 8. After installing the libdbus-1-dev package, do “make” again.

# apt-get install libdbus-1-dev

The build is completed as shown below.


Step 9. Replace wpa_supplicant as in step 6.


Step 10. When you start Wi-Fi, you can see that it works as below.
-. Now that the source code has been verified, you can try various code modifications.


Summary (Root privilege required)

1. Install the required package at build time

# apt-get install libssl-dev libnl-3-dev libnl-genl-3-dev libdbus-1-dev


2. Download the source code of wpa_supplicant

# apt-get source wpasupplicant


3. Copy wpa_supplicant Config file and add CONFIG and build

# cd wpa-2.1/wpa_supplicant
# cp defconfig .config
# vi .config

[Add CONFIG below to .config]

CFLAGS += -I/usr/include/libnl3


# make


4. Apply the generated wpa_supplicant executable file after build (existing wpa_supplicant is backed up)

# service network-manager stop
# cp /sbin/wpa_supplicant /sbin/wpa_supplicant.bk
# cp ~/wpa-2.1/wpa_supplicant/wpa_supplicant /sbin/
# service network-manager start


5 thoughts on “wpa_supplicant build/compile on Ubuntu

  1. Tentrius

    compiling – Fatal error during compilation of wpa_supplicant. Don t know what to do – Ask Ubuntu

  2. my blog

    For most recent news you have to pay a quick visit world wide web and on the web I found this web page as a finest web site for most up-to-date updates.

  3. https://goo.gl/

    Nice post. I wass checking continuously this blog annd I’m impressed!
    Very useful info specifically thee laswt part 🙂 I care for such information a lot.
    I was looking for this certain info for
    a long time. Thank you and good luck.


Leave a Reply

Your email address will not be published. Required fields are marked *