[英]"Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib" with Xcode 8?
My project requires OpenSSL libraries crypto
and ssl
.我的项目需要 OpenSSL 库crypto
和ssl
。 After updating Xcode to 8.2.1, compiling my project fails.将 Xcode 更新到 8.2.1 后,编译我的项目失败。
In my project Build Settings, in Linking , I have -lssl -lcrypto -lxml2
that indicates to load those libraries.在我的项目 Build Settings 的Linking中,我有-lssl -lcrypto -lxml2
表示加载这些库。 Going back to my app Build Settings, I add /usr/local/opt/openssl/lib/
in the Library Search Paths to tell Xcode where to look.回到我的应用程序构建设置,我在库搜索路径中添加/usr/local/opt/openssl/lib/
以告诉 Xcode 在哪里查找。
Hurray, it compiles, builds and run properly.万岁,它可以正确编译、构建和运行。 Cool.凉爽的。
BUT但
When launching the app on a different mac, the app crashes, with this linking error:在不同的 Mac 上启动应用程序时,应用程序崩溃,并出现以下链接错误:
Dyld Error Message:
Library not loaded: /usr/local/opt/openssl/lib/libssl.1.0.0.dylib
Referenced from: /Applications/MyApp.app/Contents/MacOS/MyApp
Reason: image not found
That means the app is trying to load the open ssl libraries that might not be present on that mac.这意味着该应用程序正在尝试加载该 Mac 上可能不存在的开放 ssl 库。 There might be just an older version, or that folder might not exist at all?可能只有旧版本,或者该文件夹可能根本不存在? So that's definitely a no-solution.所以这绝对是没有办法的。
Here lies my issue , I have no idea how to solve this problem.这是我的问题,我不知道如何解决这个问题。
Removing -lssl -lcrypto
from the linking doesn't help, as the has errors during linking.从链接中删除-lssl -lcrypto
没有帮助,因为链接期间有错误。
I guess I need a way to tell Xcode to look there when compiling only .我想我需要一种方法来告诉 Xcode只在编译时看那里。 Would that be possible?那可能吗?
If you don't wish to ship libraries and deal with making sure the linker can find them, you can link your code against a static library.如果您不想发送库并确保 linker 可以找到它们,您可以将您的代码与 static 库链接。
Using the code in this question as a linking example, I compiled with this command:使用此问题中的代码作为链接示例,我使用以下命令进行编译:
cc -I/opt/homebrew/Cellar/openssl@1.1/1.1.1q/include -o Link14 Link14.cpp /opt/homebrew/Cellar/openssl@1.1/1.1.1q/lib/libcrypto.a -lc++
This uses system libraries for most things, but the static version of libcrypto
in libcrypto.a
for the encryption.这在大多数情况下使用系统库,但libcrypto.a
libcrypto
加密。 You can add multiple by placing them on the compile/link line.您可以通过将它们放在编译/链接行上来添加多个。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.