简体   繁体   中英

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:

Library: /lib/libtxht/libtxht.a Xcode Project: /lib/libtxvm/myProject.xcodeproj

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.

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