Thursday, November 1, 2012

Compiling aircrack: [-Werror=unused-but-set-variable]

If you try to compile aircrack with Linux then you probably get the following error: 

# tar xf aircrack-ng-1.1.tar
# cd aircrack-ng-1.1
# make
gcc -g -W -Wall -Werror -O3 -D_FILE_OFFSET_BITS=64 -D_REVISION=0  -fPIC -I..    -c -o linux.o linux.c
linux.c: In function 'is_ndiswrapper':
linux.c:165:17: error: variable 'unused' set but not used [-Werror=unused-but-set-variable]
linux.c: In function 'linux_set_rate':
linux.c:334:22: error: variable 'unused' set but not used [-Werror=unused-but-set-variable]
cc1: all warnings being treated as errors
make[3]: *** [linux.o] Error 1
make[3]: Leaving directory `/usr/src/network/aircrack-ng-1.1/src/osdep'
make[2]: *** [all] Error 2
make[2]: Leaving directory `/usr/src/network/aircrack-ng-1.1/src/osdep'
make[1]: *** [osd] Error 2
make[1]: Leaving directory `/usr/src/network/aircrack-ng-1.1/src'
make: *** [all] Error 2

In this case just edit the file common.mak and remove the -Werror flag from the CFLAGS (nearly at the end of the file):

# vi common.mak
CFLAGS          ?= -g -W -Wall -O3

Then try to run make again. It will still show some warnings but these can be ignored and aircrack should be compiled.