• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Problem exposing class in Dynamic Library...
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Problem exposing class in Dynamic Library...


  • Subject: Problem exposing class in Dynamic Library...
  • From: Doug Wetherill <email@hidden>
  • Date: Fri, 05 Mar 2010 16:41:38 -0600

Description:

  1. Used XCODE (v3.2.1) to create a dynamic library (TestLib).
    1. Created as a "Cocoa Library".
    2. Form "External Frameworks and Libraries":
      1. Deselected "Cocoa.framework".
      2. Selected "Foundation.framework".
    3. Added to "Classes":
      1. MDWTestClass.h
      2. MDWTestClass.m
    4. Added minimal functionality to MDWTestClass, ref., code snippets below.
    5. Successfully built the dynamic library.
  2. Used XCODE to create a "Command Line Tool" of type "Foundation" (TestApp).
    1. Added code to access MDWTestClass (a component of TestLib).
    2. Modified TestApp's "Target Info":
      1. Added "../TestLib" to "Header Search Paths".
      2. Added "~/lib ../TestLib/Build/Debug" to "Library Search Paths".
    3. TestApp compiles but fails to build. 

Error Output:

"_OBJC_CLASS_$_MDWTestClass", referenced from:
__objc_classrefs__DATA@0 in TestApp.o
ld: symbol(s) not found
collect2: ld returned 1 exit status

Commentary:

Based on TestLib's link map and symbol dump (below), it appears that the symbol _OBJC_CLASS_$_MDWTestClass is defined in the __DATA segment "__objc_data" as opposed to "__objc_classlist". What am I missing?

TestLib's MDWTestClass.h:

#import <Foundation/Foundation.h>

@interface MDWTestClass : NSObject {

}
- (NSString *)message;

@end


TestLib's MDWTestClass.m:

#import "MDWTestClass.h"

@implementation MDWTestClass
- (NSString *)message
{
return @"Hello there!!!";
}
@end


TestApp's TestApp.m:

#import <Foundation/Foundation.h>
#import <MDWTestClass.h>

int main (int argc, const char * argv[]) {
    NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
    MDWTestClass *mdwObject = [[MDWTestClass alloc] init];
NSString *str = [mdwObject message];
    NSLog(@"message = %@", str);
    [pool drain];
    return 0;
}

TestLib Symbols:

new-host-2:Debug mdw$ nm -gm TestLib.dylib 
0000000000001048 (__DATA,__objc_data) external _OBJC_CLASS_$_MDWTestClass
                 (undefined) external _OBJC_CLASS_$_NSObject (from CoreFoundation)
0000000000001020 (__DATA,__objc_data) external _OBJC_METACLASS_$_MDWTestClass
                 (undefined) external _OBJC_METACLASS_$_NSObject (from CoreFoundation)
                 (undefined) external ___CFConstantStringClassReference (from CoreFoundation)
                 (undefined) external __objc_empty_cache (from libobjc)
                 (undefined) external __objc_empty_vtable (from libobjc)
                 (undefined) external dyld_stub_binder (from libSystem)
new-host-2:Debug mdw$ 

TestLib Link Map:

new-host-2:TestLib.build mdw$ cat TestLib-LinkMap-normal-x86_64.txt 
# Path: /Users/mdw/Bivariate/Projects/TestLib/build/Debug/TestLib.dylib
# Arch: x86_64
# UUID:  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0  0 
# Object files:
[  0] linker synthesized
[  1] /Users/mdw/Bivariate/Projects/TestLib/build/Debug/TestLib.dylib
# Sections:
# Address Size     Segment Section
0x00000F19 0x0000001B __TEXT __text
0x00000F34 0x0000002C __TEXT __cstring
0x00000F60 0x00000054 __TEXT __unwind_info
0x00000FB8 0x00000048 __TEXT __eh_frame
0x00001000 0x00000020 __DATA __cfstring
0x00001020 0x00000050 __DATA __objc_data
0x00001070 0x000000B0 __DATA __objc_const
0x00001120 0x00000008 __DATA __objc_classlist
0x00001128 0x00000008 __DATA __objc_imageinfo
# Symbols:
# Address Size     File  Name
0x00000F19 0x0000001B [  0] -[MDWTestClass message]
0x00000F34 0x0000000F [  0] "Hello there!!!"
0x00000F43 0x00000008 [  0] "message"
0x00000F4B 0x00000008 [  0] "@16@0:8"
0x00000F53 0x0000000D [  0] "MDWTestClass"
0x00000F60 0x00000054 [  1] unwind info
0x00000FB8 0x00000018 [  0] CIE
0x00000FD0 0x00000030 [  0] -[MDWTestClass message].eh
0x00001000 0x00000020 [  0] cfstring=Hello there!!!
0x00001020 0x00000028 [  0] _OBJC_METACLASS_$_MDWTestClass
0x00001048 0x00000028 [  0] _OBJC_CLASS_$_MDWTestClass
0x00001070 0x00000020 [  0] l_OBJC_$_INSTANCE_METHODS_MDWTestClass
0x00001090 0x00000048 [  0] l_OBJC_METACLASS_RO_$_MDWTestClass
0x000010D8 0x00000048 [  0] l_OBJC_CLASS_RO_$_MDWTestClass
0x00001120 0x00000008 [  0] __objc_classlist__DATA@0
0x00001128 0x00000008 [  1] objc$info
new-host-2:TestLib.build mdw$ 

--
Regards,
Doug





 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Xcode-users mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: Problem exposing class in Dynamic Library...
      • From: Jens Alfke <email@hidden>
  • Prev by Date: Re: cp from Xcode Shell script target
  • Next by Date: Re: Bundles and dylib lookup
  • Previous by thread: Re: Building/Running Multiple Devices Simultaneously?
  • Next by thread: Re: Problem exposing class in Dynamic Library...
  • Index(es):
    • Date
    • Thread