4

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 Answers 3

3

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.

2
  • Thanks, Pavel for your reply. I think your answer is on the right track. Some library is clearly missing when the linker behavior option is not set on Don't link. I am going to explore the differences in the build log to see if I can determine what is missing when I change this build option.
    – BruceHill
    May 11, 2011 at 7:57
  • 2
    You were correct about a dependency being missing. It turns out that the libUltralite.a is dependent on the security framework. It seems that with the linker behavior set to Don't link, this framework gets included by MonoTouch, but with the other two linker behavior options it doesn't. So the solution was to add the setting -framework Security to the gcc_flags. Now the library gets correctly linked for all linker behavior options. Thanks for your help on this, Pavel.
    – BruceHill
    May 11, 2011 at 23:51
2

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.

0

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

1
  • The third party library is an objective-c library, so it is compiled with Xcode.
    – BruceHill
    May 11, 2011 at 7:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.