# gcc can't include libnet.h



## harddriver (Jan 31, 2010)

I have installed the libnet from the port(/usr/ports/net/libnet)

when I compiled the t.c, I got an error.


```
---- t.c -----
#include <libnet.h>

.....
--------------

gcc t.c -o -lnet

====error====
t.c:2:20: error: libnet.h: No such file or directory
```


----------



## harddriver (Jan 31, 2010)

```
gcc t.c -o t -lnet
```


----------



## adamk (Jan 31, 2010)

gcc from the base system on FreeBSD does not search anywhere under /usr/local/ for headers unless you specifically tell it to.  The libnet port installs libnet.h to /usr/local/include/libnet11/.  You should probably change the include directive to:


```
#include <libnet11/libnet.h>
```

And then use gcc like so:


```
gcc -I/usr/local/include -o t -lnet t.c
```

Adam


----------



## expl (Jan 31, 2010)

you will also need this flag:

```
-L/usr/local/lib/libnet11
```


----------



## harddriver (Feb 1, 2010)

Thanks.

I finished it using the cmd

`gcc -I/usr/local/include -L/usr/local/lib -o t -lnet t.c`

and the code of t.c uses 
	
	



```
#include <libnet11/libnet.h>
```


----------

