You are not logged in.
Pages: 1
Hey all
I was toying with libnet the other day and found that it somehow refuses to link.
#include <stdio.h>
#include <stdlib.h>
#include <errno.h>
#include <libnet.h>
int main (int argc, char *argv[])
{
libnet_t *l;
char errbuf[LIBNET_ERRBUF_SIZE];
l = libnet_init(LIBNET_RAW4, argv[1], errbuf);
if ( l == NULL )
{
fprintf(stderr, "libnet_init() failed: %s\n", errbuf);
exit(EXIT_FAILURE);
}
libnet_destroy(l);
return 0;
}
Compiling is pretty straightforward, but the linking goes amiss.
gcc -Wall -g `libnet-config --defines` -c init.c
gcc -Wall `libnet-config --libs` init.o -o init
init.o: In function `main':
/home/krolden/coding/libnet/init.c:14: undefined reference to `libnet_init'
/home/krolden/coding/libnet/init.c:21: undefined reference to `libnet_destroy'
collect2: ld returned 1 exit status
libnet-config --libs resolves to "-lnet", which should normally take care of the linking against /usr/lib/libnet.a
I'm quite clueless to what the problem can be, so any help on this matter is appreciated.
Last edited by krolden (2009-06-30 20:37:35)
Offline
Try this:
gcc -Wall init.o -o init `libnet-config --libs`
Offline
O_O
It works.
So it matters in which order you specify the thing?
In any case, thanks a bunch
Offline
Pages: 1