Linker options 'Link all assemblies“ and ”Link

2019-05-07 02:40发布

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(fb6da25cb9.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.

3条回答
2楼-- · 2019-05-07 02:50

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.

查看更多
老娘就宠你
3楼-- · 2019-05-07 03:11

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.

查看更多
疯言疯语
4楼-- · 2019-05-07 03:13

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

查看更多
登录 后发表回答