开发者

Linker options 'Link all assemblies" and "Link SDK assemblies only" causes undefined symbols in 3rd party static library

Can someone please explain what is happening here. If I select Link all assemblies or Link SDK assemblies only for the linker behavior in the project build options, then I get the following linking errors occurring in my static library, libUltralite.a.

Undefined symbols:
"_SecRandomCopyBytes", referenced from:
  _zcbdb539311e3 in libUltralite.a(03b1278799.o)  
"_SecTrustSetAnchorCertificates", referenced from:
  zda160c9852f6::z41eb5883fa2f(__CFArray const*)  in libUltralite.a(fb6da25cb9.o)
"_SecKeyGetBlockSize", referenced from:
  _zd0743c47573a in libUltralite.a(f43c4e48ce.o)
"_SecCertificateCopySubjectSummary", referenced from:
  zda160c9852f6::z41eb5883fa2f(__CFArray const*)  in libUltralite.a(fb6da25cb9.o)
"_SecPolicyCreateSSL", referenced from:
  zda160c9852f6::z41eb5883fa2f(__CFArray const*)  in libUltralite.a(fb6da25cb9.o)
"_SecTrustCopyPublicKey", referenced from:
  _z2cfcc7397b7e in libUltralite.a(f43c4e48ce.o)
"_SecTrustCreateWithCertificates", referenced from:
  zda160c9852f6::z41eb5883fa2f(__CFArray const*)  in libUltralite.a(fb6da25cb9.o)
  _z2cfcc7397b7e in libUltralite.a(f43c4e48ce.o)
"_SecCertificateCreateWithData", referenced from:
  zda160c9852f6::z635831b310af(unsigned char*, unsigned long)in libUltralite.a(fb6da25cb9.o)
  _z2cfcc7397b7e in libUltralite.a(f43c4e48ce.o)
"_kSecRandomDefault", referenced from:
  _kSecRandomDefault$non_lazy_ptr in libUltralite.a(03b1278799.o)
 (maybe you meant: _kSecRandomDefault$non_lazy_ptr)
"_SecKeyEncrypt", referenced from:
  _zb27eee72717c in libUltralite.a(f43c4e48ce.o)
"_SecPolicyCreateBasicX509", referenced from:
  _z2cfcc7397b7e in libUltralite.a(f43c4e48ce.o)
"_SecTrustEvaluate", referenced from:
  zda160c9852f6::z41eb5883fa2f(__CFArray const*)  in libUltralite.a(开发者_StackOverflowfb6da25cb9.o)
  _z2cfcc7397b7e in libUltralite.a(f43c4e48ce.o)

If I instead chose Don't link for the Linker behavior, then the linking works and does not throw any errors, but the application crashes at startup on an actual iphone. The application does not crash on the simulator, it only crashes on an actual iphone. (Yes, I did recompile my static library for the actual device... so the library being included is for the correct platform).

My additional mtouch arguments under the project build options are as follows:

-v -v -v -gcc_flags "-lstdc++ -I${ProjectDir}/Ultralite/Include -L${ProjectDir}/Ultralite -lUltralite -force_load ${ProjectDir}/Ultralite/libUltralite.a"

I have concluded from a simple example that MonoTouch works correctly on the simulator and on the actual device with Linker behavior set at Link SDK assemblies only, but I am needing to find out why linking to my static library is not working correctly with this option set. If someone could shed some light on the linking errors that I am getting or propose a workaround to get my application linking correctly with this Linker behavior option set, I would be very grateful.


I think your libUltralite.a is in fact referencing some other library which you are not linking with the project, i.e. the libUltralite.a has a dependency. Check where the _SecRandomCopyBytes is being implemented (search on the drive for a header or something) to find out the actual "lib".a you need to add to the linker.


I ran into a similar problem with RestKit - but you can simply add the Security.framework to your project/target. (you don't need to add the flag manually) - well, that is if you are using XCode. If you're using command line compilation, yes, you need -framework Security.


May be You have to compile the third party with the same version of monotouch .

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜