Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

XCode 4.5, Static Libraries, and Categories

I'm trying to use a static library, and the categories that are in it aren't being used at run-time. There are no compile-time errors, but when I go to run, I get the standard 'unrecognized selector sent to instance' message and my app crashes.

Many solutions say to add -ObjC -all_load to the "Other Linker Flags" property in your application's target (many others say that as of XCode 4, that is no longer needed, this is the only reason I have bothered to include the XCode version). I've tried it and I get 115 errors during build:

Undefined symbols for architecture i386: "_CLLocationCoordinate2DMake", referenced from: -[QMapElement init] in libQuickDialog.a(QMapElement.o) "_OBJC_CLASS_$_MKMapView", referenced from: objc-class-ref in libQuickDialog.a(QMapViewController.o) "_OBJC_CLASS_$_MKPinAnnotationView", referenced from: objc-class-ref in libQuickDialog.a(QMapViewController.o) "std::istream::gcount() const", referenced from: GT::AES::decode(std::istream&, std::ostream&, unsigned int&, bool) in GD(gtaes.o) GT::AES::encode(std::istream&, std::ostream&, unsigned int&, bool) in GD(gtaes.o) "std::string::find_first_of(char const*, unsigned long, unsigned long) const", referenced from: -[GDSetPasswordViewController checkPasswordStrength:] in GD(GDSetPasswordViewController.o) GD::EacpCReq::EacpCReq(std::string, std::string, GT::Dbb&) in GD(GDEacpCommands.o) GD::RawSocket::connect() in GD(GDRawSocket.o) "std::string::copy(char*, unsigned long, unsigned long) const", referenced from: GD::Socket::toString() const in GD(GDSocket.o)

(and so on, that's about 5 or 6 of the 115).

Whether I have either of those linker flags, or both, I get the exact same set of errors.

Not sure if this is the culprit, or just coincidental, but after looking at the errors a little more closely, it seems like they are all from one of two 3rd-party libraries I am using. One as an installed .framework, the other as a regular static library. Maybe I need to do something to their builds (if possible), as well? Thanks!

like image 578
cscott530 Avatar asked Nov 20 '25 07:11

cscott530


1 Answers

It seems to me that the error message is pointing to a few missing frameworks:

  1. CoreLocation (_CLLocationCoordinate2DMake symbol);

  2. MapKit (_OBJC_CLASS_$_MKPinAnnotationView symbol);

  3. C++ standard library.

Try to include them with your target... specifically, for the C++ standard library, you should check a specific build setting in Xcode under "Apple LLVM Compiler x.y - Language".

This will not rule out the chance of other missing frameworks, of course...

like image 193
sergio Avatar answered Nov 22 '25 20:11

sergio