c++gccclangshared-libraries

How do I make the c++ compiler search for libraries in /usr/local/lib?


I am using clang on a Mac but I think this question will have the same answer for gcc (and any other unix system -- hopefully).

Right now, I can't link against libboost because it lives in /usr/local/lib. Sure, I can get it to do it with the -L/usr/local/lib and setting LD_LIBRARY_PATH to include /usr/local/lib, but I want my system to search for libraries and includes in /usr/local without the need to specify it in the command line.

Is there a way to do this?


Solution

  • To let your system do this automaticly, you can specify the enviroment variable LIBRARY_PATH (Enviroment Variables) to you library directory (/usr/local/lib).

    To make this permanent, just declare this variable in your .bashrc, or similar.

    Another way is to change the specs of gcc.

    Indeed, this a summary from this question: How to add a default include path for gcc in linux?