richards
richards

Reputation: 527

g++ compilation with gsl: library not found

Hi I'm trying to install and use GSL library following this guide: Install GSL on Mac. The brew installation works fine and I can see the file in path: /usr/local/include. Then I tried with the sample c code, but when I compile it gives me this error: symbol(s) not found for architecture x86_64. I searched and referred to this answer here: g++ error, so I added -lgsl to the command, sth like:

g++ -I/usr/local/include -lgsl main.c

But it gives: ld: library not found for -lgsl error. How can I resolve this? Thank you!

Upvotes: 2

Views: 4114

Answers (1)

richards
richards

Reputation: 527

Yeah the solution should be this:

g++ -I/usr/local/include -L/usr/local/lib -lgsl main.c

This works. Refer to the answer here:Install GSL. Basically what -I gives you is the headers, while we also need the -L statement to link the library.

Upvotes: 1

Related Questions