1

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?

Carneiro
  • 3,479
  • 5
  • 24
  • 36
  • `/usr/local` is included in the default search path on my Mac. What versions of things are you using? – Carl Norum Jul 22 '13 at 21:43
  • possible duplicate of [Is /usr/local/lib searched for shared libraries?](http://stackoverflow.com/questions/4743233/is-usr-local-lib-searched-for-shared-libraries) – Iwan Aucamp Jul 22 '13 at 22:11

1 Answers1

0

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?

Community
  • 1
  • 1
Amadeus
  • 10,199
  • 3
  • 25
  • 31
  • This is not really the correct way, see this answer: http://stackoverflow.com/a/4743253/1598080 – Iwan Aucamp Jul 22 '13 at 22:10
  • This make the system to find the shared libraries, but the problems remains in how to compile. So this does not solve this problem. Indeed, looking at the link "Enviroment Variables", it says that: `LIBRARY_PATH ... Linking using GCC also uses these directories when searching for ordinary libraries for the -l option` – Amadeus Jul 22 '13 at 22:20
  • From `man ld` (for GNU ld): `The linker uses the following search paths to locate required shared libraries:` ... `8. For a native linker on an ELF system, if the file /etc/ld.so.conf exists, the list of directories found in that file.`. – Iwan Aucamp Jul 22 '13 at 22:44
  • for osx you will probbably look at something similar to this [ldconfig(8) for freebsd](http://www.freebsd.org/cgi/man.cgi?query=ldconfig&sektion=8&apropos=0&manpath=FreeBSD+9.1-RELEASE) – Iwan Aucamp Jul 22 '13 at 22:47