3

我目前正在使用 libGDX 开发一个小型多平台游戏。该游戏在 Windows、Android 和 OSX 上运行良好,但我无法让它为 iOS 编译。

iOS的libGDX 指南提出了一些注意事项,但我很确定我已经考虑了一切。我有 Eclipse、Xamarin.iOS、JDK、Ant 和 $PATH,$IKVM_HOME 已按应有的方式设置。gamename.dll(它是 Mono 编译的 dll,包含我所有的游戏逻辑,由 Java 代码自动生成)已经创建,一切看起来都井井有条。

但是,在编译时,我收到以下错误消息:

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)

(为简洁起见,路径缩写了一点。)

这些参数由 libGDX 在创建 iOS 项目时自动生成,在 Xamarin 的项目设置中如下所示:

-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"

构建输出包含以下内容:

/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 是 libGDX 在创建项目时自动添加的引用 dll 之一。

我认为这意味着我的设置有问题,但我找不到任何看起来相关的东西。

有任何想法吗?

编辑:添加 poupou 建议的框架后,我现在收到一条略有不同的错误消息: EDIT1b:不,实际上是一样的。唯一的区别是论点。

/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"
4

2 回答 2

3

您的本机库之一(libObjectAL来自您的日志)需要AVFoundation框架与您的应用程序链接。

注意:您可以从未找到的类型的前缀中猜到这一点_AV*

解决方案:添加-framework AVFoundation到您-gcc_flags的应用程序并重建您的应用程序。

于 2013-06-20T14:45:20.863 回答
2

所以-framework AVFoundation需要,至少如果您的应用程序不引用MonoTouch.AVFoundation. 在后一种情况下,框架将自动链接。

OTOH 这三个符号还有一个共同点:它们都是iOS6中的新符号。

它使我们的您正在针对 iOS 5.1 构建,即

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

所以符号不存在(在AVFoundation.framework被引用中),您libObjectAL-universal.a对丢失的符号不满意。

从那里你有两个选择:

  1. 将您的最低构建版本设置为 iOS6(已经拥有 93% 的市场);

  2. 尝试查找(或构建)一个libObjectAL不依赖于 iOS 6 API 的应用程序。

于 2013-06-21T13:49:22.617 回答