I'm trying to compile my libnet script and am getting this error:
[root@whyme]# gcc -Wall `libnet-config --defines` mysocket.cc -o mysocket `libnet-config --libs` -lpcap -lnet
/tmp/ccUPbuVg.o: In function `main':
mysocket.cc:(.text+0x1e): undefined reference to `net_init'
mysocket.cc:(.text+0x2a): undefined reference to `net_loadconfig'
mysocket.cc:(.text+0x35): undefined reference to `net_detectdrivers'
mysocket.cc:(.text+0x40): undefined reference to `net_initdrivers'
mysocket.cc:(.text+0x54): undefined reference to `net_openconn'
mysocket.cc:(.text+0x83): undefined reference to `net_listen'
mysocket.cc:(.text+0xbe): undefined reference to `net_poll_listen'
mysocket.cc:(.text+0xd2): undefined reference to `net_closeconn'
mysocket.cc:(.text+0xf1): undefined reference to `net_receive_rdm'
mysocket.cc:(.text+0x11b): undefined reference to `net_query_rdm'
I didn't paste my code because this looks like it's related to linking the objects.
I'm able to compile & execute this source file with your exact command (changing only the filenames): https://github.com/repolho/Libnet-1.1-tutorial-examples/blob/master/01_init.c
I therefore suspect the problem is in your source after all. Most libnet function names are of the form libnet_[funcname], but in your linker errors I see names of the form net_[funcname].
I also note that you've manually inserted -lnet. On my system, -lnet is the entire output of libnet-config --libs, so if you do need it specifying it manually is redundant. It's not harmful, but you can type fewer characters next time. :)