简体   繁体   中英

Building open source library (liblo) for iPhone

I've got an iPhone project using liblo (liblo.sourceforge.net). My project's been working fine in the simulator, but as soon as I went to build for the device, ld fails:

ld: library not found for -llo

I suspect that this is because I just ran make install when I downloaded liblo. 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.

[/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. http://www.samvermette.com/files/liblo.a.zip

Just add it to your XCode project and you're ready to go!

I wrote a small tutorial on building cross platform iPhone libs that run both on the device and the simulator.

Here's an updated version of jkooker's config script, for 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. 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. 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.

As noted in my comment to the @mikewoz answer, I have updated the fat lib script and used it for many years. I attempted to use this approach and generate an XCFramework via

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. 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. So far I opted for using configure and set the following defines: -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. That being said, I have only tested on my M1 MacBook Pro 13, so I hope this approach works on Intel machines.

If anyone needs the working liblo.xcodeproj, you can find it here: 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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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