scroot / gopacket

Automatically exported from code.google.com/p/gopacket
BSD 3-Clause "New" or "Revised" License
0 stars 1 forks source link

Can't compile with PF_RING support #10

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1. Install PF_RING using this manual on Debian 7 Wheezy: 
http://www.stableit.ru/2014/06/pfring-debian-7-wheezy.html
2. cp /opt/pf_ring/include/pfring.h /usr/include/; cp /opt/pf_ring/lib/* 
/usr/lib/
3. go get "code.google.com/p/gopacket/pfring" 

What is the expected output?
Compiled tool

What do you see instead?
 go get "code.google.com/p/gopacket/pfring"
# code.google.com/p/gopacket/pfring
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libpfring.so: undefined 
reference to `numa_node_of_cpu'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libpfring.so: undefined 
reference to `clock_gettime'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libpfring.so: undefined 
reference to `numa_bind'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libpfring.so: undefined 
reference to `numa_parse_nodestring'
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libpfring.so: undefined 
reference to `numa_available'

After this I added numa to linker config in 
/usr/share/go/src/pkg/code.google.com/p/gopacket/pfring/pfring.go and got new 
error:
go get "code.google.com/p/gopacket/pfring" 
/# code.google.com/p/gopacket/pfring
/usr/lib/gcc/x86_64-linux-gnu/4.7/../../../../lib/libpfring.so: undefined 
reference to `clock_gettime'
collect2: error: ld returned 1 exit status

For solve this I added 'rt' to linker config and tool builded successfully.

All compiles correctly with this flags:
#cgo LDFLAGS: -lpfring -lpcap -lnuma -lrt

Please fix it! 

What version of the product are you using? On what operating system?
go version go1.0.2

Original issue reported on code.google.com by pavel.odintsov on 12 Jun 2014 at 5:29

GoogleCodeExporter commented 9 years ago
And you can remove pcap because it optional for PF_RING in native mode.

Original comment by pavel.odintsov on 14 Jun 2014 at 6:59

GoogleCodeExporter commented 9 years ago
Are you able to compile a C/C++ binary that uses PF_RING with your current 
setup?

These errors look like they may be related to a broken install of pfring, just 
want to make sure we check that out.

Original comment by gconnell@google.com on 16 Jun 2014 at 4:46

GoogleCodeExporter commented 9 years ago
Hello!

I created simple  programm for checking PF_RING compilation: 
https://gist.github.com/pavel-odintsov/62f372c882c83d85ed17

And tried to compile it with same results:
gcc test_pf_ring.c  -lpfring -lpcap
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/libpfring.so: 
undefined reference to `clock_gettime'
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/libpfring.so: 
undefined reference to `numa_parse_nodestring'
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/libpfring.so: 
undefined reference to `numa_node_of_cpu'
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/libpfring.so: 
undefined reference to `numa_available'
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/libpfring.so: 
undefined reference to `numa_bind'

Problem was fixed in same way (I added -lnuma -lrt):
gcc test_pf_ring.c -lpfring -lpcap -lnuma
/usr/lib/gcc/x86_64-redhat-linux/4.4.7/../../../../lib64/libpfring.so: 
undefined reference to `clock_gettime'

All compiles fine with this code: gcc test_pf_ring.c -lpfring -lpcap -lnuma -lrt

Original comment by pavel.odintsov on 16 Jun 2014 at 5:15

GoogleCodeExporter commented 9 years ago
I suppose this issue related with my pf_ring compilation flags, I used non 
standard option --disable-bpf for disabling linking to pcap because it's 
obsolete. Without this flag all works pretty well but only on modern pcap 
library version. 

I think you can close this issue because my compilation flags is non standard. 

Original comment by pavel.odintsov on 16 Jun 2014 at 7:44

GoogleCodeExporter commented 9 years ago
Thanks for the heads-up!

I'll add a comment in pfring.go so others with the same issues can find out 
what's going on.  Just to be clear, the addition of -lnuma and -lrt are 
necessary if using --disable-bpf with pfring?

Original comment by gconnell@google.com on 16 Jun 2014 at 7:53