如何将 fftw3 和 sndfile 等第三方库链接到 Xcode 中的 iPhone 项目?
我正在尝试将 fftw3 和 sndfile 等第三方库链接到 Xcode3.2 中的 iPhone 项目。我通过在项目构建配置下将“标题搜索路径”设置为“/usr/local/include”并将“其他链接器标志”设置为“-lfftw3 -lsndfile”,使其在常规 Mac 项目中工作。然而,当我尝试使用相同的设置在 iPhone 项目中构建它时,它给了我“找不到 -lfftw3 的库”和退出代码 1 错误消息。
苹果不允许在 iPhone 上这样做吗?有办法解决这个问题吗?
I'm trying to link third party libraries like fftw3 and sndfile to my iPhone project in Xcode3.2. I got it working in a regular Mac project by setting the "Header Search Path" to "/usr/local/include" and the "Other Linker Flags" to "-lfftw3 -lsndfile" under the project build configuration. However, it gave me "library not found for -lfftw3" with exit code 1 error message when I tried to build it in the iPhone project using the same settings.
Does apple not allow this on the iPhone? Is there a way to get around this?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(9)
我已针对 IOS 5.0+ 修改了 Epskampie 的脚本
在带有 IOS SDK 6.0 和 MacOSX SDK 10.8 的 OS X 10.7 上与 fftw3.3.3 一起使用
I've modified Epskampie's script for IOS 5.0+
Used with fftw3.3.3 on OS X 10.7 with IOS SDK 6.0 and MacOSX SDK 10.8
为了编译 fftw3 以在 iOS 项目中使用,我修改了此处发布的脚本:
http://robertcarlsen.net/2009/07/15 /cross-compiling-for-iphone-dev-884
在带有 iOs SDK 3.2 的 OS X 10.6 上与 fftw3.2.2 一起使用
从包含 fftw3 的目录运行此脚本。您需要的文件最终应位于 ios-library 文件夹中。
For compiling fftw3 for use in an iOS project, i've adapted the script posted here:
http://robertcarlsen.net/2009/07/15/cross-compiling-for-iphone-dev-884
Used with fftw3.2.2 on OS X 10.6 with iOs SDK 3.2
Run this script from the directory containing fftw3. The files you need should end up in the ios-library folder.
您需要将库构建为通用静态库。这个过程因图书馆而异,但通常是这样的。
第 1 步通常是最棘手的,因为许多库都有不同的构建过程。通常通过设置正确的编译器标志来使用 iphone sdk 而不是系统范围的编译器来完成。
You need to build your libraries as universal static libraries. The process varies from library to library but it generally goes something like this.
Step 1 is generally the trickiest since many libraries have different build procedures. It is usually done by setting the proper compiler flags to use the iphone sdk instead of the system wide compiler.
我针对 Mac OS X 10.9.2、iOS 7.1、fftw-3.3.4 修改了 Nickun 的脚本。它还向 fat 文件添加一个 arm64 切片。这是脚本 ->
I modified Nickun's script for Mac OS X 10.9.2, iOS 7.1, fftw-3.3.4. It also adds an arm64 slice to the fat file. Here is the script ->
基于 10mitri 的回答,适用于 fftw-3.3.8、iOS SDK 12.2、XCode 10.2。
Based on the answer by 10mitri, working for fftw-3.3.8, iOS SDK 12.2, XCode 10.2.
并不是 Apple 不允许该库,而是您链接到的版本是 x86,因此它无法在 iPhone 上运行。您需要使用 iPhone SDK 构建库,然后链接到该版本。
或者,您可以顽皮一点,将第 3 方源代码包含在您的主项目中。顽皮,但它会证明苹果不会阻止你,并显示该库是否可以在手机上运行。
不过,将代码保存在单独构建的库项目中会更干净。
It's not that Apple isn't allowing the library, it's that the version you are linking to is x86, and so it won't run on the iPhone. You need to build the library using the iPhone SDK, then link to that version.
Alternatively, you can be a little naughty and include the 3rd-party source in your main project. Naughty, but it'll prove the point that Apple isn't stopping you, and show whether the library will run on the phone OK.
It's cleaner to keep the code in a separately-built library project though.
为 iOS 构建 FFTW3:
这是一个为不同 iOS 架构(设备、模拟器等)创建 .h 和 .a 文件的脚本,
尽情享受吧!
Build FFTW3 for iOS:
Here is a script to create .h and .a files for different iOS architectures (device, simulator, ...)
Enjoy it!
我尝试了亚当·弗里曼的脚本,它很棒,但我必须执行以下操作才能使其正常工作,
所以我在这里分享我的发现。我的目标是制作基于arm的fftw lib,这样我就可以使用arm架构通过Xcode构建它++ lib
我也遇到了loretoparisi发布的问题,
解决方法是去掉“tests”、“tools”文件夹和任何fftw的make规则- Makefile.in 和 Makefile.am 中的“wisdom”相关内容,我不知道这两个文件夹中的文件有多重要,但我必须删除它们,以便 fftw 构建能够成功而不会出现 UTF-8 错误
我也必须修改脚本(我唤醒了霓虹灯和浮动精度标志,同样我也不知道这些标志有多重要)
I tried Adam Freeman's script, its awesome but I had to do the following to make it work,
so I am here to share my finding. My goal is to make arm based fftw lib so I can build it++ lib through Xcode with arm architecture
I also run into the problem posted by loretoparisi
the workaround is to strip away the make rule for "tests","tools" folders and any fftw-"wisdom" related stuff in Makefile.in and Makefile.am, I don't know how important are the files from those two folders, but I had to remove them so fftw build can success without UTF-8 error
I also have to modify the script (I took awake the neon and float precision flag, again I also do not know how important are those flag)
我已将以前的脚本改编为
与 XCODE7 iOS9.3 MACOSX 10.11 FFTW 3.3.4 配合使用
根据@Ninji,您必须修改
Makefile.am
和
Makefile.in
I've adapted previous scripts to
WORK WITH XCODE7 iOS9.3 MACOSX 10.11 FFTW 3.3.4
According with @Ninji you have to modify
Makefile.am
and
Makefile.in