今天晚上编译一个libnids方面的程序。头文件包含了"libnids.h"。但是编译的时候还是出错。如下:
tmp/ccnCpNW6.o: In function `main':
sample.c:(.text+0x331): undefined reference to `nids_init'sample.c:(.text+0x33d): undefined reference to `nids_register_tcp'
sample.c:(.text+0x342): undefined reference to `nids_run'
collect2: ld returned 1 exit status
后来查了下。原来是我编译的方式不对。
libnids库编译的时候需要pcap和net库,所以编译参数不对
应该为 gcc -g -o test test.c -lnids -lpcap -lnet。
成功。