views:

1118

answers:

3

Hello all!

I've built my own static library with components to be reused in my project, and recently had the need to update a bunch of classes. Specifically, some methods' signatures were changed due to the fact that some classes changed names.

What happens now is that the library compiles fine on its own, but, when added to an app project, the project fails to link:

Ld build/Sucursales.build/Debug-iphoneos/Sucursales.build/Objects-normal/armv6/Sucursales normal armv6
cd /Users/nameghino/src/Sucursales
setenv IPHONEOS_DEPLOYMENT_TARGET 3.1
setenv PATH "/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin"
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc-4.2 -arch armv6 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk -L/Users/nameghino/src/Sucursales/build/Debug-iphoneos -L/Users/nameghino/src/Sucursales/../../Library/MyLibraries/MSSharedLibrary-1.0.0 -F/Users/nameghino/src/Sucursales/build/Debug-iphoneos -filelist /Users/nameghino/src/Sucursales/build/Sucursales.build/Debug-iphoneos/Sucursales.build/Objects-normal/armv6/Sucursales.LinkFileList -dead_strip -lxml2 -ObjC -all_load -miphoneos-version-min=3.1 -framework Foundation -framework UIKit -framework CoreGraphics -lsqlite3.0 -framework CoreLocation -framework MapKit -lxml2 /Users/nameghino/src/MSSharedComponents/Frameworks/MSSharedLibrary/build/Debug-iphoneos/libMSSharedLibrary.a -o /Users/nameghino/src/Sucursales/build/Sucursales.build/Debug-iphoneos/Sucursales.build/Objects-normal/armv6/Sucursales

Undefined symbols:
  "_OBJC_CLASS_$_DataCatalogService_GetSingleRow", referenced from:
      objc-class-ref-to-DataCatalogService_GetSingleRow in libMSSharedLibrary.a(MSDataCatalogSpecification.o)
  **"_OBJC_CLASS_$_DataCatalogService_ArrayOfString", referenced from:
      objc-class-ref-to-DataCatalogService_ArrayOfString in libMSSharedLibrary.a(MSDataCatalogSpecification.o)
  "_OBJC_CLASS_$_DataCatalogService_GetSingleRowResponse", referenced from:
      objc-class-ref-to-DataCatalogService_GetSingleRowResponse in libMSSharedLibrary.a(MSSingleRowResultsParser.o)
  "_OBJC_CLASS_$_DataCatalogService_GetMultiRowResponse", referenced from:
      objc-class-ref-to-DataCatalogService_GetMultiRowResponse in libMSSharedLibrary.a(MSMultiRowResultsParser.o)
  "_OBJC_CLASS_$_DataCatalogService_GetMultiRow", referenced from:
      objc-class-ref-to-DataCatalogService_GetMultiRow in libMSSharedLibrary.a(MSDataCatalogSpecification.o)
  "_OBJC_CLASS_$_DataCatalogService_HelloWorldResponse", referenced from:
      objc-class-ref-to-DataCatalogService_HelloWorldResponse in libMSSharedLibrary.a(DataCatalogService.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status**

The curious thing is that after a lot of project cleanups (both in the app and the lib projects), I still get the same issue. Even after starting a new project, the problem is still there.

I've also taken care to restart Xcode between a clean and a build a couple of times, but no good.

Any ideas on where to look?

Thanks in advance

Nico

+1  A: 

Have you added the library as a dependency to the project? See http://stackoverflow.com/questions/87979/beginner-question-about-xcode-3-1-1-and-static-libraries#88583

If you drill down into your target, does the library name appear in the "Link binary with libraries" group?

Look at the log for the compiler/linker output. Find the call to the linker. Does your library appear on the list of static libraries to link in?

Shaggy Frog
Thanks for your answer!Yes, the library is a dependency for the project.Yes, the library name is in the "Link binary with libraries" group.Yes, as a matter of fact, the linker call is in the pastie above.
Nico
+1  A: 

Have you solve the problem ?

I am using a .a library and i have a similar problem while linking my project files :

Undefined symbols:
"_OBJC_CLASS_$_SUPMessageClient", referenced from:
  objc-class-ref-to-SUPMessageClient in SUPWorkFlowsAppDelegate.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

In the linker log, I can see my -l.

Any idea ?

spawnrider
Sorry, unfortunately, I couldn't solve the issue, other than falling back to an older version of my library. Since then, I haven't been able to look back into the issue, but, now that you've brought it back, I may take a look at it again.
Nico
+1  A: 

I just encountered the same linker error. I discovered through trial and error that it was because I was invoking isKindOfClass. I'm not sure why this causes the linker to barf, but hopefully this information helps out.

The class in question, OrderItem, is a child of NSManagedObject; in other words, it's an automatically-generated Core Data entity class.

Specifically, here was the linker error:

"_OBJC_CLASS_$_OrderItem", referenced from:
objc-class-ref-to-OrderItem in libmyStaticLib.a(MyTableViewController.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status

And here was the offending code:

- (void)handleButtonTapWithObject:(id)object
{
    // This must be an OrderItem or else we don't want to touch it:
    if ( NO == [object isKindOfClass:[OrderItem class]] ) // <-- OFFENDING CODE
    {
        NSLog(@"Object parameter is of unexpected type.");
        return;
    }

My workaround was simply to omit the test that ensures 'object' is an OrderItem. The code is not as secure without this test, but the linker error went away. I'd be curious to know if I am going about this test wrong, and perhaps there is a better way of doing this.

Jeffro