32

I'm a bit confused.

I've installed a bunch of libraries (e.g. vtk, gsl,...) that I need for a c++ project for school. I used homebrew to install them (luckily there were formulas available).

My question is, does Homebrew link these into /usr/include or something comparable? Or is this something I would need to do manually?

Homebrew usually does this kind of stuff for executables, yet I can't seem the find the libraries anywhere other than in the /usr/local/Cellar/... directories. I have a bunch of libraries installed so I can't simply use -L/... for each of them.

1
  • Shouldn't whatever is in the Cellar be linked to the /usr/local? If it is a project, then I'd suggest using a Makefile; it would make things easier, does it not?
    – ismail
    Commented Feb 17, 2012 at 12:09

3 Answers 3

18

They are usually linked in /usr/local/lib (Intel Macs) or /opt/homebrew/lib/ (M1 Macs). If they are not there, try brew link <library-you-are-installing>; that should solve it.

0
18

For recent versions of Homebrew, installed libraries (for example, SDL) will be located in $(brew --prefix)/lib as symlinks. Their corresponding header files will be in $(brew --prefix)/include. Generally, when building C or C++ projects you can set the following:

export LDFLAGS="-L/opt/homebrew/lib"
export CPPFLAGS="-I/opt/homebrew/include"

Usually though, these directories will be automatically discovered and used.

Some Rust projects might require you to set the LIBRARY_PATH variable like so:

export LIBRARY_PATH="$LIBRARY_PATH:$(brew --prefix)/lib"
3
  • As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.
    – Community Bot
    Commented Dec 31, 2021 at 15:56
  • 1
    What uses LIBRARY_PATH? It is not the normal thing used in makefiles
    – mmmmmm
    Commented Dec 31, 2021 at 17:24
  • Rust tends to use it for crates that wrap C/C++ libraries.
    – Menace
    Commented Dec 31, 2021 at 22:39
0

Use brew info <package> to find where a package is installed. You can add the --verbose option to see the full list of installed files.

1
  • 1
    --verbose doesn't show the list of installed files. For that, use brew ls <package>
    – hmijail
    Commented Jul 20, 2022 at 2:15

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .