简体   繁体   中英

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!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM