• 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
Re: Symbol not found when compiling MM (ObjC++) file
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Symbol not found when compiling MM (ObjC++) file


  • Subject: Re: Symbol not found when compiling MM (ObjC++) file
  • From: Kyle Sluder <email@hidden>
  • Date: Fri, 05 Aug 2011 21:02:28 -0700

On Aug 5, 2011, at 7:57 AM, Alexander Hartner <email@hidden> wrote:

>
> Logger.h
>
> #import <Foundation/Foundation.h>
> void ABSLogToggle (BOOL debug);
> void ABSLog (NSString *format,...);

[snip]

>
> Now when I import Logger.h and use it from a Objective C (.m) file everything seems to work great. However as soon I as import it and use it from a Objective C++ (.mm) file I get the following link error:
>
> Ld [REMOVED] normal i386
> setenv MACOSX_DEPLOYMENT_TARGET 10.4
> /Developer/usr/bin/g++-4.0 -arch i386 -dynamiclib -isysroot /Developer/SDKs/MacOSX10.4u.sdk -L[REMOVED]/Release -F[REMOVED]/Release -filelist [REMOVED].LinkFileList -install_name [REMOVED] -mmacosx-version-min=10.4 -framework Foundation -framework Cocoa -framework SyncServices -framework Foundation -framework IOKit -lcrypto.0.9.7 -lssl.0.9.7 -single_module -compatibility_version 1 -current_version 9 -o [REMOVED]
>
> Undefined symbols:
>  "ABSLog(NSString*, ...)", referenced from:
>      -[SoapAdaptor initWithPreferences:] in SoapAdaptor.o
> ld: symbol(s) not found
> collect2: ld returned 1 exit status

You need to wrap the contents of your header file with `extern "C"` when building C++:

#import <Foundation/Foundation.h>

#ifdef __cplusplus
extern "C" {
#endif

void ABSLogToggle(BOOL debug);
void ABSLog(NSString *format,...);

#ifdef __cplusplus
}
#endif

--Kyle Sluder_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

References: 
 >Symbol not found when compiling MM (ObjC++) file (From: Alexander Hartner <email@hidden>)

  • Prev by Date: Re: NSTask vmrun
  • Next by Date: Re: Symbol not found when compiling MM (ObjC++) file
  • Previous by thread: Re: Symbol not found when compiling MM (ObjC++) file
  • Next by thread: Re: Symbol not found when compiling MM (ObjC++) file
  • Index(es):
    • Date
    • Thread