Compiling problem with libipq
Friends.
I hope this is the correct list
This is very frustrating and I am sure there is a simple solution...
The code...
#include <linux/netfilter.h>
#include <libipq/libipq.h>
struct ipq_handle * ph_ipq = 0;
intmain(int argc, char * argv[]){
ph_ipq = ipq_create_handle(0, PF_INET);
return 0;
}
Compiling....
make -k
gcc -g -O0 -DIPT_LIB_DIR=/usr/lib -c ip_q_test.c -o ip_q.o gcc -g -O0 -DIPT_LIB_DIR=/usr/lib -lipq ip_q.o -o ip_q
ip_q.o: In function `main':/home/worik/Projects/project12/ip_q_test.c:6: undefined reference to `ipq_create_handle'
Oh dear! Use the -shared flag (?)
gcc -g -O0 -DIPT_LIB_DIR=/usr/lib -fpic -shared -c ip_q_test.c -o
ip_q.o
gcc -g -O0 -DIPT_LIB_DIR=/usr/lib -fpic -shared -lipq ip_q.o -oip_q
Running....
This GDB was configured as "i386-linux"... (gdb) b main
Breakpoint 1 at 0x773: file ip_q_test.c, line 6. (gdb) r
Starting program: /home/worik/Projects/project12/ip_q Breakpoint 1 at 0x80000773: file ip_q_test.c, line 6.
Program received signal SIGSEGV, Segmentation fault. 0x00000001 in ?? ()
(gdb)
What have I done wrong? Clearly there is a problem with libraries,
probably libipq.
So check for it...
nm /usr/lib/libipq.a|grep ipq_create_handle
00000218 T ipq_create_handle
I do not know enough about nm to be sure, but I think this is OK.
I am using debian woody with the packages iptables and iptables-dev installed. Version 1.2.6a-5
Worik
Quoted 1 line · Worik
gcc -g -O0 -DIPT_LIB_DIR=/usr/lib -lipq ip_q.o -o
ip_q
Try putting -lipq at the end of the end of this line.
Signature · 2 lines
James Morris <[email protected]>