Owatch Owatch - 1 year ago 95
C Question

Linking a Static C Library in Xcode 7?

I'm currently trying to link a static C library I've created to a fresh Xcode project. To link it, I followed the following instructions:

1) Navigate to Build Phases

2) Expand Link Binaries With Library

3) Added an "other" library, and then specified the .a file in question.

Unfortunately, the project won't compile and throws the following error:

ld: library not found for -ltxht

I'm not sure exactly what to make of this. The library seems to appear okay in the project as a project file, and I can't find any indication that there is anything wrong with that.

I've tried setting it's location to Use Absolute Path in the file-inspector, but that didn't change anything.

I've also seen that in some similar online posts that somehow providing the full path to the static library might help resolve the problem:

In reaction to your comment on Eduard Wirch' answer: you can also control static linking for this one library only, if you replace -lhdf5 by -l/full/path/to/libhdf5.a

From this SO Post.

However, I'm not sure how to do this? I've gone into Build Settings and seen nothing but pages of options, but there isn't much under Headers or Linking that seems to allow me to do what I want.

Can anyone explain how to correctly add this static C library? Just for your information, the location of the project relative to the location of the library is as follows:


Xcode Project:

Answer Source

If this is an external static lib, you need to add the path it exists to Library Search Paths under Build Settings. Not the full path, just the directory it is in.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download