简体   繁体   English

链接Xcode 7中的静态C库?

[英]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. 我目前正在尝试将我创建的静态C库链接到一个新的Xcode项目。 To link it, I followed the following instructions: 要链接它,我按照以下说明操作:

1) Navigate to Build Phases 1)导航到Build Phases

2) Expand Link Binaries With Library 2) 使用库展开链接二进制文件

3) Added an "other" library, and then specified the .a file in question. 3)添加了“其他”库,然后指定了相关的.a文件。

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 回应你对Eduard Wirch回答的评论:如果用-l / full / path / to / libhdf5.a替换-lhdf5,你也可以只为这一个库控制静态链接

From this SO Post . 这个SO帖子

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. 我已经进入了构建设置 ,除了选项页面之外什么都没看到,但是在HeadersLinking下没有多少似乎允许我做我想要的。

Can anyone explain how to correctly add this static C library? 任何人都可以解释如何正确添加这个静态C库? 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 库: /lib/libtxht/libtxht.a Xcode项目: /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. 如果这是外部静态库,则需要将其存在的路径添加到Library Search Paths构建设置Library Search Paths下的“ Library Search Paths ”。 Not the full path, just the directory it is in. 不是完整路径,只是它所在的目录。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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