kmiklas
kmiklas

Reputation: 13433

Using GSL with Xcode 7 - Link Error

I am attempting to use the GSL library with Xcode, but I can't get it to link.

Efforts so far, based on hours of searching:
1. Downloaded GSL libary v2.1.
http://www.gnu.org/software/gsl/
2. Followed installation directions in README.
3. Xcode build settings:
a. "Other C++ Flags:" -I/usr/local/include
b. "Header Search Paths:" /usr/local/include/
c. "Framework Search Paths:" /library/Frameworks
d. "C/C++/Objective C compiler:" Default Compiler (Apple LVVM 7.0)

I tried to change the compiler to GCC, but the option is not there.

Somewhere I was referred to the Accelerate Mathematics framework. I would prefer to use the GNU tool. I realize that when using a Mac, I am in The World According to Apple, and must play by their rules, but I would hate to dump the GSL library for this reason. Furthermore, it seems that support for this framework seems to be minimal. https://developer.apple.com/library/mac/navigation/#section=Frameworks&topic=Accelerate

Also reference this post, which is dated, but has some relevant comments from users wrestling with this issue in previous versions of Xcode:
Xcode 4.3.3 can't find any header files

Integrating GSL with Xcode

Error: enter image description here

Upvotes: 2

Views: 2611

Answers (1)

kmiklas
kmiklas

Reputation: 13433

Got it. For posterity, the solution is as follows.

  1. First, be sure to follow the instructions in the INSTALL file included in the GSL download. You can't just download, unzip, and include. You have to build the library. Read all the steps before you begin; they're a little out of order. For example, after the summary--which is what I plunged into--you are told that the first two of the following commands should be run as a normal user; only the third as root.

Briefly, the shell commands `./configure; make; make install' should configure, build, and install this package.

  1. Next, in your Xcode target, two flags must be set in Build Settings

a. Search Paths/Header Search Paths: /usr/local/include
b. Linking/Other Linker Flags: -I/usr/local/include -L/usr/local/lib -lgsl -lgslcblas

Hope this helps someone out there.

enter image description here

enter image description here

Upvotes: 3

Related Questions