insmod Error: Invalid module format [How to Solve]

Compiling kernel modules

$ make M=/home/liyongjun/project/c/linux-4.4.1/net/mac80211/ modules

Installation error

$ sudo insmod net/mac80211/mac80211.ko 
insmod: ERROR: could not insert module net/mac80211/mac80211.ko: Invalid module format

dmesg

$ dmesg
...
[ 3187.509374] mac80211: no symbol version for module_layout

Solution:

Add the -C /lib/modules/`uname -r`/build option

$ make -C /lib/modules/`uname -r`/build M=/home/liyongjun/project/c/linux-4.4.1/net/mac80211/ modules

Read More: