xcode 在 iPhone SDK 3.0 中链接静态库
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/1095145/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Linking Static Libraries in iPhone SDK 3.0
提问by pix0r
I have an iPhone app that heavily relies on the OpenCV library; as such, I've compiled a static version of this library for inclusion with my app. The instructions for doing this are relatively straightforward: Using OpenCV on iPhone. The only gotcha I ran into was setting the linker flag, STANDARD_C_PLUS_PLUS_LIBRARY_TYPE
to "standard
". The app compiled and ran perfectly under OS 2.0 and 2.2.
我有一个严重依赖 OpenCV 库的 iPhone 应用程序;因此,我编译了这个库的静态版本以包含在我的应用程序中。执行此操作的说明相对简单:在 iPhone 上使用 OpenCV。我遇到的唯一问题是将链接器标志设置STANDARD_C_PLUS_PLUS_LIBRARY_TYPE
为“ standard
”。该应用程序在 OS 2.0 和 2.2 下编译并完美运行。
After upgrading to SDK 3.0 and trying to re-compile my app, I'm running into an issue with this linker flag. I'm getting this error while linking:
升级到 SDK 3.0 并尝试重新编译我的应用程序后,我遇到了此链接器标志的问题。链接时出现此错误:
ld: library not found for -lstdc++-static
ld:找不到用于 -lstdc++-static 的库
It's also interesting that on my system, "libstdc++-static" is present under seemingly every iPhoneOS and iPhoneSimulator SDK except for iPhoneOS.platform/SDKs/iPhoneOS3.0.sk. Here are the search results:
有趣的是,在我的系统上,除了 iPhoneOS.platform/SDKs/iPhoneOS3.0.sk 之外,似乎每个 iPhoneOS 和 iPhoneSimulator SDK 下都存在“libstdc++-static”。以下是搜索结果:
$ locate libstdc++-static
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk/usr/lib/libstdc++-static.a
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk/usr/lib/libstdc++-static.a
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.1.sdk/usr/lib/libstdc++-static.a
/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.2.sdk/usr/lib/libstdc++-static.a
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.0.sdk/usr/lib/libstdc++-static.a
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.1.sdk/usr/lib/libstdc++-static.a
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.1.sdk/usr/lib/libstdc++-static.a
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator2.2.sdk/usr/lib/libstdc++-static.a
/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk/usr/lib/libstdc++-static.a
/Developer/SDKs/MacOSX10.4u.sdk/usr/lib/libstdc++-static.a
/Developer/SDKs/MacOSX10.5.sdk/usr/lib/libstdc++-static.a
/usr/lib/libstdc++-static.a
I'm pretty baffled and haven't been able to find any answers on Google or iPhone dev forums. I'd really appreciate if someone could shed some light here.
我很困惑,无法在 Google 或 iPhone 开发论坛上找到任何答案。如果有人能在这里有所启发,我将不胜感激。
Thanks!
谢谢!
采纳答案by John
Just a guess - try adding one of the directories to the 'Library Search Paths' option in Build Properties?
只是猜测 - 尝试将其中一个目录添加到“构建属性”中的“库搜索路径”选项中?
回答by hhafez
That is truly puzziling, only thing I can think of is that /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk
is not in your library search path but that would be very unlikely.
这真是令人费解,我唯一能想到的是它/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator3.0.sdk
不在您的图书馆搜索路径中,但这不太可能。