无法链接MonoTouch项目中的本机库 - 找不到-lName的库

时间:2014-07-25 09:50:59

标签: binding xamarin.ios xamarin native

我已经在xcode中编译了flacios library。然后我提取了一个"胖二进制文件"从framework文件夹(这个特定的xcode项目的构建工件)并将其重命名为libFLACiOS.a。

然后我将其添加到MonoTouch应用程序项目中。创建了一个NativeMethods包装器类,我在其中导入我需要使用的本机方法,并为项目选项添加了一个gcc标志:

  

-cxx -gcc_flags&#34; -std = c ++ 11 -stdlib = libc ++ -lc ++ -v -Wall -L $ {ProjectDir} -lFLACiOS -framework AVFoundation -force_load $ {ProjectDir} /libFLACiOS.a < / p>

现在,似乎我已经完成了导入工作所需的一切,但是当我尝试构建项目时,我得到以下构建错误:

/Developer/MonoTouch/usr/bin/mtouch -sdkroot "/Applications/Xcode.app/Contents/Developer" --cache "/Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache" --nomanifest --nosign -dev "/Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/bin/iPhone/Debug/Sigmo.app" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Xml.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/System.Core.dll" -r "/Developer/MonoTouch/usr/lib/mono/2.1/monotouch.dll" -debug -linksdkonly -sdk "7.1" -targetver "7.0" --abi=armv7 "-cxx" --gcc_flags "\"-std=c++11\" \"-stdlib=libc++\" \"-lc++\" \"-v\" \"-Wall\" \"-L/Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo\" \"-lFLACiOS\" \"-framework\" \"AVFoundation\" \"-force_load\" \"/Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/libFLACiOS.a\"" "/Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/bin/iPhone/Debug/Sigmo.exe"
Xamarin.iOS 7.2.5 Trial Edition using framework: /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk
Process exited with code 1, command:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++  -Wl,-pie  -miphoneos-version-min=7.0 -arch armv7 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk  /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/Sigmo.exe.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/monotouch.dll.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/mscorlib.dll.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/System.dll.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/System.Core.dll.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/registrar.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/main.armv7.o -o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/bin/iPhone/Debug/Sigmo.app/Sigmo -framework CFNetwork -framework AVFoundation -framework QuartzCore -framework CoreBluetooth -framework Foundation -framework AudioToolbox -framework CoreGraphics -framework UIKit -lz -liconv -u _mono_pmip -u _monotouch_release_managed_ref -u _monotouch_create_managed_ref -u _xamarin_get_block_descriptor -u _monotouch_IntPtr_objc_msgSend_IntPtr -u _monotouch_log /Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonoboehm-2.0.a /Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonotouch-debug.a "-std=c++11" "-stdlib=libc++" "-lc++" "-v" "-Wall" "-L/Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo" "-lFLACiOS" "-framework" "AVFoundation" "-force_load" "/Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/libFLACiOS.a"
Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
Target: arm-apple-darwin13.3.0
Thread model: posix
 "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch armv7 -force_load /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/libFLACiOS.a -iphoneos_version_min 7.0.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -u _mono_pmip -u _monotouch_release_managed_ref -u _monotouch_create_managed_ref -u _xamarin_get_block_descriptor -u _monotouch_IntPtr_objc_msgSend_IntPtr -u _monotouch_log -o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/bin/iPhone/Debug/Sigmo.app/Sigmo -L/Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo -pie /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/Sigmo.exe.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/monotouch.dll.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/mscorlib.dll.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/System.dll.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/System.Core.dll.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/registrar.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/main.armv7.o -framework CFNetwork -framework AVFoundation -framework QuartzCore -framework CoreBluetooth -framework Foundation -framework AudioToolbox -framework CoreGraphics -framework UIKit -lz -liconv /Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonoboehm-2.0.a /Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonotouch-debug.a -lc++ -lFLACiOS -framework AVFoundation -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.ios.a
Undefined symbols for architecture armv7:
  "std::string::c_str() const", referenced from:
      FLAC::Decoder::File::init(std::string const&) in libFLACiOS.a(stream_decoder-823A661D997F1576.o)
      FLAC::Decoder::File::init_ogg(std::string const&) in libFLACiOS.a(stream_decoder-823A661D997F1576.o)
      FLAC::Encoder::File::init(std::string const&) in libFLACiOS.a(stream_encoder-20FCC1D902B5C661.o)
      FLAC::Encoder::File::init_ogg(std::string const&) in libFLACiOS.a(stream_encoder-20FCC1D902B5C661.o)
ld: symbol(s) not found for architecture armv7
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error MT5309: Native linking error: Apple LLVM version 5.1 (clang-503.0.40) (based on LLVM 3.4svn)
error MT5309: Native linking error: Target: arm-apple-darwin13.3.0
error MT5309: Native linking error: Thread model: posix
error MT5309: Native linking error: "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld" -demangle -dynamic -arch armv7 -force_load /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/libFLACiOS.a -iphoneos_version_min 7.0.0 -syslibroot /Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.1.sdk -u _mono_pmip -u _monotouch_release_managed_ref -u _monotouch_create_managed_ref -u _xamarin_get_block_descriptor -u _monotouch_IntPtr_objc_msgSend_IntPtr -u _monotouch_log -o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/bin/iPhone/Debug/Sigmo.app/Sigmo -L/Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo -pie /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/Sigmo.exe.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/monotouch.dll.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/mscorlib.dll.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/System.dll.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/System.Core.dll.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/registrar.armv7.o /Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/obj/iPhone/Debug/mtouch-cache/main.armv7.o -framework CFNetwork -framework AVFoundation -framework QuartzCore -framework CoreBluetooth -framework Foundation -framework AudioToolbox -framework CoreGraphics -framework UIKit -lz -liconv /Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonoboehm-2.0.a /Developer/MonoTouch/SDKs/MonoTouch.iphoneos.sdk/usr/lib/libmonotouch-debug.a -lc++ -lFLACiOS -framework AVFoundation -lc++ -lSystem /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../lib/clang/5.1/lib/darwin/libclang_rt.ios.a
error MT5210: Native linking failed, undefined symbol: std::string::c_str() const. Please verify that all the necessary frameworks have been referenced and native libraries are properly linked in.
error MT5201: Native linking failed. Please review the build log and the user flags provided to gcc: "-std=c++11" "-stdlib=libc++" "-lc++" "-v" "-Wall" "-L/Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo" "-lFLACiOS" "-framework" "AVFoundation" "-force_load" "/Users/maxpavlov/Perforce/max.pavlov_Moment_5440/Mobile/Sigmo/SigmoIOS/Sigmo/libFLACiOS.a"
error MT5202: Native linking failed. Please review the build log.

1 个答案:

答案 0 :(得分:0)

由于FLAC.a,您似乎在告诉本地链接器链接-lFLAC

但是你说FLACiOS.a存在,这是一个不同的文件名。您是否尝试将其更改为匹配,即-lFLACiOS