背景
在 Ubuntu 16.04 下安装Cbench时出现了以下的错误
libtool: link: gcc -g -O2 -Wall -I/home/yxchen/oflops/../openflow//include -Wshadow -Wl,-E -o oflops channel_info.o context.o control.o module_run.o module_default.o oflops.o oflops_pcap.o timer_event.o msg.o log.o traffic_generator.o usage.o -L/home/yxchen/oflops/../openflow//lib -ldl -lpcap /home/yxchen/oflops/.libs/liboflops_test.a -lconfig -lpthread -lnetsnmp
traffic_generator.o: In function `get_next_pkt':
/home/yxchen/oflops/traffic_generator.c:140: undefined reference to `time_diff'
collect2: error: ld returned 1 exit status
Makefile:577: recipe for target 'oflops' failed
make[2]: *** [oflops] Error 1
make[2]: Leaving directory '/home/ubuntu/mtcbench/oflops'
Makefile:642: recipe for target 'all-recursive' failed
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory '/home/ubuntu/mtcbench/oflops'
Makefile:434: recipe for target 'all' failed
make: *** [all] Error 2
查看traffic_generator.c
后发现函数time_diff
是有定义的,于是怀疑是依赖没装好的问题。
解决
- git clone https://github.com/intracom-telecom-sdn/mtcbench.git
- cd /path/to/mtcbench # 打开mtcbench的文件夹
- ./deploy/docker/provision.sh # 这个脚本会安装所有需要的依赖
然后回到oflops的文件夹下make clean再make就可以了。
参考
error: undefined reference to time_diff possibly due to missing dependencies