linux2.6.36以上安装aodv-uu-0.9.6

时间:2021-03-23 03:58:56

由于Linux内核版本的问题,在2.6.36以上安装aodv-uu-0.9.6会出现以下问题:

gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o main.o main.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o list.o list.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o debug.o debug.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o timer_queue.o timer_queue.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o aodv_socket.o aodv_socket.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o aodv_hello.o aodv_hello.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o aodv_neighbor.o aodv_neighbor.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o aodv_timeout.o aodv_timeout.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o routing_table.o routing_table.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o seek_list.o seek_list.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o aodv_rreq.o aodv_rreq.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o aodv_rrep.o aodv_rrep.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o aodv_rerr.o aodv_rerr.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o nl.o nl.c
In file included from nl.c:38:
lnx/kaodv-netlink.h:89: warning: type defaults to ‘int’ in declaration of ‘DECLARE_MUTEX’
lnx/kaodv-netlink.h:89: warning: parameter names (without types) in function declaration
lnx/kaodv-netlink.h:89: warning: ‘DECLARE_MUTEX’ declared ‘static’ but never defined
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -c -o locality.o locality.c
gcc -Wall -O3 -g -DDEBUG -DCONFIG_GATEWAY  -DDEBUG -o aodvd main.o list.o debug.o timer_queue.o aodv_socket.o aodv_hello.o aodv_neighbor.o aodv_timeout.o routing_table.o seek_list.o aodv_rreq.o aodv_rrep.o aodv_rerr.o nl.o locality.o 
make -C /home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx KERNEL_DIR=/lib/modules/2.6.38-8-generic/build KCC=gcc XDEFS=-DDEBUG
make[1]: 正在进入目录 `/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx'
make -C /lib/modules/2.6.38-8-generic/build SUBDIRS=/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx modules
make[2]: 正在进入目录 `/usr/src/linux-headers-2.6.38-8-generic'
  CC [M]  /home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-mod.o
In file included from /home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-mod.c:48:
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.h:89: warning: type defaults to ‘int’ in declaration of ‘DECLARE_MUTEX’
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.h:89: warning: parameter names (without types) in function declaration
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.h:89: warning: ‘DECLARE_MUTEX’ declared ‘static’ but never defined
  CC [M]  /home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-debug.o
In file included from /home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-debug.c:26:
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.h:89: warning: type defaults to ‘int’ in declaration of ‘DECLARE_MUTEX’
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.h:89: warning: parameter names (without types) in function declaration
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.h:89: warning: ‘DECLARE_MUTEX’ declared ‘static’ but never defined
  CC [M]  /home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.o
In file included from /home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.c:37:
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.h:89: warning: type defaults to ‘int’ in declaration of ‘DECLARE_MUTEX’
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.h:89: warning: parameter names (without types) in function declaration
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.c:45: warning: type defaults to ‘int’ in declaration of ‘DECLARE_MUTEX’
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.c:45: warning: parameter names (without types) in function declaration
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.c: In function ‘kaodv_netlink_fini’:
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.c:367: error: ‘kaodvnl_sem’ undeclared (first use in this function)
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.c:367: error: (Each undeclared identifier is reported only once
/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.c:367: error: for each function it appears in.)
make[3]: *** [/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx/kaodv-netlink.o] 错误 1
make[2]: *** [_module_/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx] 错误 2
make[2]:正在离开目录 `/usr/src/linux-headers-2.6.38-8-generic'
make[1]: *** [kaodv.ko] 错误 2
make[1]:正在离开目录 `/home/fire/aodv-uu-0.9.6/aodv-uu-0.9.6/lnx'
make: *** [kaodv] 错误 2


查找DECLARE_MUTEX:

在include/linux/semaphore.h 中

将#define DECLARE_MUTEX(name)   改成了 #define DEFINE_SEMAPHORE(name) 

 

#if LINUX_VERSION_CODE < KERNEL_VERSION(2,6,36)

DECLARE_MUTEX(led_sem);

#else

DEFINE_SEMAPHORE(led_sem);

#endif


因此将kaodv-netlink.c中

static DECLARE_MUTEX(kaodvnl_sem);

修改为:static DEFINE_SEMAPHORE(kaodvnl_sem);

make clean

make

即可