简体   繁体   English

在 Xcode 中编译失败,因为找不到链接库

[英]Compiling in Xcode fails because linked lib isn't found

I need the openssl lib for some C code in my iPhone App.我的 iPhone 应用程序中的一些 C 代码需要 openssl 库。 So I've put the lib into my project.所以我把这个库放到了我的项目中。

But when I compile it, Xcode throws me some errors:但是当我编译它时, Xcode 会抛出一些错误:

error: openssl/ssl.h: No such file or directory错误:openssl/ssl.h:没有这样的文件或目录

That's my code for including:这是我的代码,包括:

 #include <openssl/ssl.h>

Target settings in Xcode: Xcode 中的目标设置:

alt text http://img17.imageshack.us/img17/2266/bild3tez.png替代文字 http://img17.imageshack.us/img17/2266/bild3tez.png

Which step am I missing to link it correctly?我错过了正确链接它的哪一步?

This is not a linking issue.这不是链接问题。 This is the preprocessor not being able to locate the header file.这是预处理器无法找到 header 文件。 You need to check where that header ended up, and perhaps alter Xcode's (or your project's) settings to include that location.您需要检查 header 的最终位置,并可能更改 Xcode(或您的项目)的设置以包含该位置。

Since this appears to be for iPhone, you won't find it.由于这似乎适用于 iPhone,因此您不会找到它。 OpenSSL is not available on the iPhone, not to third-party applications anyway. OpenSSL 在 iPhone 上不可用,对第三方应用程序也不可用。 Compiling for the simulator might work, because it has all kinds of stuff that real devices don't.为模拟器编译可能会起作用,因为它有各种真实设备没有的东西。 Getting this to compile for the phone is a non-starter-- the header's not found because it's not there, and if you somehow trick it into using a different copy, it'll fail to link.让它为手机编译是不可能的——找不到标头,因为它不存在,如果你以某种方式欺骗它使用不同的副本,它将无法链接。

OpenSSL for iPhone is available at http://www.therareair.com/2009/01/01/tutorial-how-to-compile-openssl-for-the-iphone/适用于 iPhone 的 OpenSSL 可在http://www.therareair.com/2009/01/01/tutorial-how-to-compile-openssl-for-the-iphone/获得

Compiled libraries too at end of article.文章末尾也编译了库。

Well, when a linked lib isn't found I now go here to see which library/framework I need to link to.好吧,当找不到链接的库时,我现在 go 在这里查看我需要链接到哪个库/框架。

I know your problem was something else, but this should be useful for others.我知道您的问题是其他问题,但这对其他人应该有用。

http://developer.apple.com/iPhone/library/documentation/Xcode/Conceptual/iphone_development/910-A-iPhone_Simulator_Frameworks/iphone_simulator_frameworks.html http://developer.apple.com/iPhone/library/documentation/Xcode/Conceptual/iphone_development/910-A-iPhone_Simulator_Frameworks/iphone_simulator_frameworks.html

Also, to link the libraries, go to the targets area of xcode.此外,要将库 go 链接到 xcode 的目标区域。 Expand that area until you find "link binary with libraries".展开该区域,直到找到“将二进制文件与库链接”。 Right click and add existing framework.右键单击并添加现有框架。 Click the plus at the bottom and then find the library you need and add it.单击底部的加号,然后找到您需要的库并添加它。

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

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