简体   繁体   English

为 iPhone 构建开源库 (liblo)

[英]Building open source library (liblo) for iPhone

I've got an iPhone project using liblo (liblo.sourceforge.net).我有一个使用 liblo (liblo.sourceforge.net) 的 iPhone 项目。 My project's been working fine in the simulator, but as soon as I went to build for the device, ld fails:我的项目在模拟器中运行良好,但是当我为设备构建时, ld失败了:

ld: library not found for -llo

I suspect that this is because I just ran make install when I downloaded liblo.我怀疑这是因为我在下载 liblo 时刚刚运行了make install I found a thread that suggested cross compiling by running ./configure --host=arm-apple-darwin before make install , but that doesn't seem to have fixed the problem.我发现一个线程建议通过在make install之前运行./configure --host=arm-apple-darwin进行交叉编译,但这似乎并没有解决问题。

[/usr/local/lib]$ file liblo.dylib 
liblo.dylib: Mach-O dynamically linked shared library i386

Is there a simple solution?有一个简单的解决方案吗?

Well here's the file, compiled for OS 3.0.这是为 OS 3.0 编译的文件。 http://www.samvermette.com/files/liblo.a.zip http://www.samvermette.com/files/liblo.a.zip

Just add it to your XCode project and you're ready to go!只需将它添加到您的 XCode 项目中,您就可以开始了!

Here's an updated version of jkooker's config script, for iOS 4: http://gist.github.com/519121这是 jkooker 配置脚本的更新版本,适用于 iOS 4: http://gist.github.com/519121

Bringing this up again...又要提这个了。。。

Xcode 12.3+ has deprecated manually-linked fat libs generated via lipo in favor of XCFrameworks. Xcode 12.3+ 已弃用通过 lipo 生成的手动链接的脂肪库,以支持 XCFrameworks。 Basically, M1 macs now share the same arm64 arch as iDevices and Xcode is not able to tell which arch to use within the fat lib, so will fail to link the arm64 slice when running in the simulator.基本上,M1 mac 现在与 iDevices 共享相同的 arm64 arch,Xcode 无法判断在 fat lib 中使用哪个 arch,因此在模拟器中运行时将无法链接 arm64 slice。 If you only run on device via Xcode on an M1 mac, it does work but it's less than ideal to not have the Simulator as an option.如果您仅在 M1 mac 上通过 Xcode 在设备上运行,它确实可以工作,但不将模拟器作为选项并不理想。

As noted in my comment to the @mikewoz answer, I have updated the fat lib script and used it for many years.正如我在对@mikewoz 回答的评论中指出的那样,我已经更新了 fat lib 脚本并使用了很多年。 I attempted to use this approach and generate an XCFramework via我试图使用这种方法并通过生成 XCFramework

xcodebuild -create-xcframework -library liblo-ios.a -library liblo-sim.a -output liblo.xcframework

...however I was not able to get this to work. ......但是我无法让它发挥作用。

In the end, I have opted for building the liblo sources myself via a manually-created liblo static lib Xcode project.最后,我选择通过手动创建的 liblo static lib Xcode 项目自己构建 liblo 源。 This works fine and just requires setting the required defines, either via config.h generated via configure , or setting them manually on the Xcode project.这工作正常,只需要通过configure生成的 config.h 设置所需的定义,或者在 Xcode 项目上手动设置它们。 So far I opted for using configure and set the following defines: -DHAVE_CONFIG_H -DAC_APPLE_UNIVERSAL_BUILD -Qunused-arguments -fno-common -DPIC .到目前为止,我选择使用configure并设置以下定义: -DHAVE_CONFIG_H -DAC_APPLE_UNIVERSAL_BUILD -Qunused-arguments -fno-common -DPIC The AC_APPLE_UNIVERSAL_BUILD define is used to enable a compile-time endinaness check in config.h. AC_APPLE_UNIVERSAL_BUILD定义用于启用 config.h 中的编译时结束检查。 That being said, I have only tested on my M1 MacBook Pro 13, so I hope this approach works on Intel machines.也就是说,我只在我的 M1 MacBook Pro 13 上测试过,所以我希望这种方法适用于英特尔机器。

If anyone needs the working liblo.xcodeproj, you can find it here: https://github.com/danomatika/PdParty/tree/master/libs/liblo如果有人需要可用的 liblo.xcodeproj,您可以在这里找到它: https://github.com/danomatika/PdParty/tree/master/libs/liblo

The steps used to automate the downloading and configuring of the liblo sources are in the main libs Makefile:https://github.com/danomatika/PdParty/blob/master/libs/Makefile用于自动下载和配置 liblo 源的步骤在主库 Makefile 中:https://github.com/danomatika/PdParty/blob/master/libs/Makefile

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

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