3

I am currently developing a small multiplatform game with libGDX. The game works great on Windows, Android and OSX, but I can't make it compile for iOS.

The libGDX guide for iOS states a couple of caveats, but I'm pretty sure I have taken everything into account. I have Eclipse, Xamarin.iOS, JDK, Ant, and $PATH, $IKVM_HOME is set as they should. The gamename.dll (which is the Mono compiled dll that contains all my game logic, and is automatically generated from the Java code) has been created, and everything looks to be in order.

When compiling, however, I get the following error message:

Error MT5201: Native linking failed. Please review user flags provided to gcc: "-L/Users/blah/Ultralyd/Ultralyd-ios/libs/ios" "-L/Users/blah/Ultralyd/Ultralyd-ios/libs/ios/ikvm/bin" "-likvm-natives" "-lgdx" "-force_load" "/Users/blah/Ultralyd/Ultralyd-ios/libs/ios/libgdx.a" "-force_load" "/Users/blah/Ultralyd/Ultralyd-ios/libs/ios/ikvm/bin/libikvm-natives.a" (MT5201)

(Paths abbreviated a little bit for brevity.)

These arguments are automatically generated by libGDX when creating the iOS project, and looks like this in Xamarin's project settings:

-nosymbolstrip -nostrip -cxx -gcc_flags "-L${ProjectDir}/libs/ios -L${ProjectDir}/libs/ios/ikvm/bin -likvm-natives -lgdx -force_load ${ProjectDir}/libs/ios/libgdx.a -force_load ${ProjectDir}/libs/ios/ikvm/bin/libikvm-natives.a"

The build output contains this:

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++  -Wl,-no_pie -arch i386 -gdwarf-2 -fobjc-legacy-dispatch -fobjc-abi-version=2 -miphoneos-version-min=3.2 -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk  /Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/obj/iPhoneSimulator/Debug/mtouch-cache/main.i386.cache.vqL1439yU4Eq3JVRLyBeXkLz910=.o -o /var/folders/4p/g1k6g_v51kn35jm5yyh3g74m0000gq/T/tmp1da69439.tmp/iosgame -framework CFNetwork -framework Foundation -framework OpenGLES -framework UIKit -framework AVFoundation -framework QuartzCore -framework CoreGraphics -framework OpenAL -framework AudioToolbox -lz -liconv -u _mono_pmip -u _monotouch_create_managed_ref -u _monotouch_release_managed_ref -u _monotouch_IntPtr_objc_msgSend_IntPtr -u _monotouch_IntPtr_objc_msgSendSuper_IntPtr -u _CloseZStream -u _CreateZStream -u _Flush -u _ReadZStream -u _WriteZStream -lmono-2.0 -lmonotouch-debug -L/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib -u _catch_exception_raise  -force_load /var/folders/4p/g1k6g_v51kn35jm5yyh3g74m0000gq/T/tmp1da69439.tmp/libObjectAL-universal.a "-L/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios" "-L/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios/ikvm/bin" "-likvm-natives" "-lgdx" "-force_load" "/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios/libgdx.a" "-force_load" "/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios/ikvm/bin/libikvm-natives.a"
Process exited with code 1, command:
/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++  -Wl,-no_pie -arch i386 -gdwarf-2 -fobjc-legacy-dispatch -fobjc-abi-version=2 -miphoneos-version-min=3.2 -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk  /Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/obj/iPhoneSimulator/Debug/mtouch-cache/main.i386.cache.vqL1439yU4Eq3JVRLyBeXkLz910=.o -o /var/folders/4p/g1k6g_v51kn35jm5yyh3g74m0000gq/T/tmp1da69439.tmp/iosgame -framework CFNetwork -framework Foundation -framework OpenGLES -framework UIKit -framework AVFoundation -framework QuartzCore -framework CoreGraphics -framework OpenAL -framework AudioToolbox -lz -liconv -u _mono_pmip -u _monotouch_create_managed_ref -u _monotouch_release_managed_ref -u _monotouch_IntPtr_objc_msgSend_IntPtr -u _monotouch_IntPtr_objc_msgSendSuper_IntPtr -u _CloseZStream -u _CreateZStream -u _Flush -u _ReadZStream -u _WriteZStream -lmono-2.0 -lmonotouch-debug -L/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib -u _catch_exception_raise  -force_load /var/folders/4p/g1k6g_v51kn35jm5yyh3g74m0000gq/T/tmp1da69439.tmp/libObjectAL-universal.a "-L/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios" "-L/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios/ikvm/bin" "-likvm-natives" "-lgdx" "-force_load" "/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios/libgdx.a" "-force_load" "/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios/ikvm/bin/libikvm-natives.a"
Undefined symbols for architecture i386:
  "_AVAudioSessionInterruptionNotification", referenced from:
      -[OALAudioSession init] in libObjectAL-universal.a(OALAudioSession.o)
  "_AVAudioSessionInterruptionTypeKey", referenced from:
      -[OALAudioSession handleInterruption:] in libObjectAL-universal.a(OALAudioSession.o)
  "_AVAudioSessionInterruptionOptionKey", referenced from:
      -[OALAudioSession handleInterruption:] in libObjectAL-universal.a(OALAudioSession.o)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

libObjectAL is one of the referenced dlls that was added automatically by libGDX when creating the project.

I assume this means that there is something wrong with my settings, but I can't find anything that looks like it is related.

Any ideas?

EDIT: After adding the framework suggested by poupou, I now get a slightly different error message: EDIT1b: No, it's actually the same. The only difference are the arguments.

/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++  -Wl,-no_pie -arch i386 -gdwarf-2 -fobjc-legacy-dispatch -fobjc-abi-version=2 -miphoneos-version-min=3.2 -arch i386 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk  /Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/obj/iPhoneSimulator/Debug/mtouch-cache/main.i386.cache.1rmDllI2qRyDYwNzBd+9+oPccNg=.o -o /var/folders/4p/g1k6g_v51kn35jm5yyh3g74m0000gq/T/tmp141160e6.tmp/iosgame -framework CFNetwork -framework Foundation -framework OpenGLES -framework UIKit -framework AVFoundation -framework QuartzCore -framework CoreGraphics -framework OpenAL -framework AudioToolbox -lz -liconv -u _mono_pmip -u _monotouch_create_managed_ref -u _monotouch_release_managed_ref -u _monotouch_IntPtr_objc_msgSend_IntPtr -u _monotouch_IntPtr_objc_msgSendSuper_IntPtr -u _CloseZStream -u _CreateZStream -u _Flush -u _ReadZStream -u _WriteZStream -lmono-2.0 -lmonotouch-debug -L/Developer/MonoTouch/SDKs/MonoTouch.iphonesimulator.sdk/usr/lib -u _catch_exception_raise  -force_load /var/folders/4p/g1k6g_v51kn35jm5yyh3g74m0000gq/T/tmp141160e6.tmp/libObjectAL-universal.a "-framework" "AVFoundation" "-L/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios" "-L/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios/ikvm/bin" "-likvm-natives" "-lgdx" "-force_load" "/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios/libgdx.a" "-force_load" "/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios/ikvm/bin/libikvm-natives.a"
Undefined symbols for architecture i386:
  "_AVAudioSessionInterruptionNotification", referenced from:
      -[OALAudioSession init] in libObjectAL-universal.a(OALAudioSession.o)
  "_AVAudioSessionInterruptionTypeKey", referenced from:
      -[OALAudioSession handleInterruption:] in libObjectAL-universal.a(OALAudioSession.o)
  "_AVAudioSessionInterruptionOptionKey", referenced from:
      -[OALAudioSession handleInterruption:] in libObjectAL-universal.a(OALAudioSession.o)
ld: symbol(s) not found for architecture i386
collect2: ld returned 1 exit status

error MT5201: Native linking failed. Please review user flags provided to gcc: "-framework" "AVFoundation" "-L/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios" "-L/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios/ikvm/bin" "-likvm-natives" "-lgdx" "-force_load" "/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios/libgdx.a" "-force_load" "/Users/erlenddahl/Copy/UltralydDebugging/Libgdx/Ultralyd/Ultralyd-ios/libs/ios/ikvm/bin/libikvm-natives.a"
Erlend D.
  • 3,013
  • 6
  • 37
  • 59

2 Answers2

3

One of your native libraries (libObjectAL from your logs) requires the AVFoundation framework to be linked with your application.

Note: you can somewhat guess this from the _AV* prefix of the types that were not found.

Solution: Add -framework AVFoundation to your -gcc_flags and rebuild your application.

poupou
  • 43,413
  • 6
  • 77
  • 174
  • Thanks, that's probably a step the right direction, but I now get "i686-apple-darwin11-llvm-g++-4.2: AVFoundation: No such file or directory" instead. I assume this means that I need to include AVFoundation in the Xamarin solution somewhere, but I can't figure out where it is, nor how to add it. – Erlend D. Jun 21 '13 at 08:40
  • It must be inside your `-gcc_flags` since it's a directive you're giving to the native (Apple) linker. OTOH I made a typo (fixed), it should have been `-framework AVFoundation`, not `--framework AVFoundation` (only one `-`). – poupou Jun 21 '13 at 12:59
  • Thanks, but it seems to make no difference, see my edit in the original post. The error message seems to be identical, but I can see that "-framework" "AVFoundation" is now added at the end of the first line. Note, however, that it looks like this framework is already included (if you scroll horizontally to a little bit before the center, "-framework AVFoundation" is there already, together with a lot of other frameworks). – Erlend D. Jun 21 '13 at 13:22
  • Can you pastebin (and add a link to) your complete build log ? – poupou Jun 21 '13 at 13:43
  • Yep, here it is: http://pastebin.com/xVwQ3cWX The first part is a libGDX script that builds the Mono-dll. (Up to the last "Writting method", I believe.) – Erlend D. Jun 21 '13 at 13:47
2

So -framework AVFoundation is needed, at least if your application does not refer to types in MonoTouch.AVFoundation. In that later case the framework will automagically be linked.

OTOH the three symbols have another thing in common: they are all new in iOS6.

And it turns our you're building against iOS 5.1, i.e.

-isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator5.1.sdk

So the symbols are not present (in the AVFoundation.framework being referenced) and your libObjectAL-universal.a is not pleased with the missing symbols.

From there you have two choices:

  1. Set your minimum build version to iOS6 (which already has 93% of the market);

  2. Try to find (or build) a libObjectAL without dependencies on iOS 6 API.

poupou
  • 43,413
  • 6
  • 77
  • 174
  • Ah, thanks! I'd love to set my minimum build version, but I can only find 5.1. Is there something I haven't installed properly? In Options => iOS Build => SDK version, I have only two options: "5.1" and "Default". In iOS Application => Deployment Target, I have a lot of versions, but none higher than 5.1. 3.2 is currently selected. In the build dropdown, I can select "iPad Simulator 5.1" or "iPhone Simulator 5.1", none for 6.1. I have XCode version 4.3.2, and Xamarin version 4.0.8b2. Am I missing anything obvious? – Erlend D. Jun 21 '13 at 14:25
  • That's because your version of Xcode, which includes the iOS SDK, is too old (it was released before 6.0 became available). You'll need to update it for 4.5 (or 4.6) to get iOS 6 (or 6.1) SDK support. – poupou Jun 21 '13 at 14:37
  • 1
    Yep, that solved the problem. Thank you very much! (Sorry it took me so long to check your answer -- it was a company Mac, so naturally, it took me all of four days to acquire the needed permissions to update Xcode.) – Erlend D. Jun 27 '13 at 08:26