# cc / gcc cannot find any libraries / header files



## harishankar (May 10, 2010)

I have a problem with my (own) C programs. gcc cannot find any of my header files or libraries.
`$ gcc -lcgi -o info.cgi info.c`

When I compile I get this error:

```
info.c:3:17: error: cgi.h: No such file or directory
```

(I installed cgilib and cgi.h is in /usr/local/include/)

Then when I manually fix the path then I get a linker error as so:

```
/usr/bin/ld: cannot find -lcgi
```


----------



## harishankar (May 10, 2010)

Well I found the solution, but it's still not linking properly  I get this

```
/var/tmp//cc0OSfPg.o(.text+0xae): In function `main':
: undefined reference to `cgi_init'
/var/tmp//cc0OSfPg.o(.text+0xb8): In function `main':
: undefined reference to `cgi_process_form'
/var/tmp//cc0OSfPg.o(.text+0xc2): In function `main':
: undefined reference to `cgi_init_headers'
/var/tmp//cc0OSfPg.o(.text+0x194): In function `main':
: undefined reference to `cgi_param'
```


----------



## SirDice (May 10, 2010)

Add the -L and -l options to gcc to add the right directories. The /usr/local/include/ and /usr/local/lib/ directories aren't included by default.


----------



## harishankar (May 10, 2010)

Yes, but it still gives the linker errors above after adding -I and -L


----------

