0

I want to add a C-Library in order to include it in Code simply by typing:

#include <libname>

It works when I'm using the full path like so:

#include "path/to/lib.h"

Is there a way to add the lib to some kind of standard location, where gcc will find it?

I've tried the following but it didn't work for me: How to add default Include and Library path for gcc in Macos for bash?

(both echo $LD_LIBRARY_PATH and echo $DYLD_LIBRARY_PATH are empty and copying all *.h-Files to /usr/local/ also didn't work.)

Thank you very much in advance for your help!

sahu
  • 1
  • `#include` searches for a file named `libname` on the system include path. It's possible although highly unusual not to use a suffix for an include file (usually `.h` in C) -- perhaps that's what you're doing wrong? A minimal but complete example that shows the problem would be helpful for your question. – Paul Hankin Apr 24 '21 at 10:37
  • https://gcc.gnu.org/onlinedocs/gcc-4.9.2/cpp/Search-Path.html provides information about how gcc finds `#include`d files in both the `<>` and `""` forms – Paul Hankin Apr 24 '21 at 10:41
  • Remember you need *both* the library path and the include path for headers. – tadman Apr 24 '21 at 11:04
  • Re “copying all *.h-Files to /usr/local/ also didn't work”: Did you copy the `.h` files to `/usr/local` or to `/usr/local/include`? The latter is the correct location for header files. – Eric Postpischil Apr 24 '21 at 11:14

0 Answers0