Re: Symbol not found when compiling MM (ObjC++) file
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:11:27 -0700
More useful info lives here: http://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html
--Kyle Sluder
On Aug 5, 2011, at 7:57 AM, Alexander Hartner <email@hidden> wrote:
> I am constructing a framework consisting of C++, ObjectiveC and ObjectiveC++ files. As part of the framework I have created a wrapper around NSLog so I can control and disable log messages centrally. I know there are better ways to do this, however right now I need to get this working and don't have the luxury of evaluating various logging frameworks. Basically I have a
>
> Logger.h
>
> #import <Foundation/Foundation.h>
> void ABSLogToggle (BOOL debug);
> void ABSLog (NSString *format,...);
>
> Logger.m
>
> #import "Logger.h"
>
> int absDebug = NO;
>
> void ABSLogToggle (BOOL debug)
> {
> absDebug = debug;
> }
>
> void ABSLog (NSString * format,...)
> {
> if (absDebug == NO)
> {
> }
> else
> {
> va_list args;
> va_start(args, format);
> NSString * message = [[NSString alloc] initWithFormat:format arguments:args];
> NSLog(@"ABSLOG : %@",message);
> va_end(args);
> }
> }
>
> 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
>
> Both the logger and the other classes are part of the same target and are packaged together. I checked that the logger.h file is included in the framework with public access and that it is included in the Header file of my framework. However the error occurs during the construction of my framework. As the entire target is configured to compile on the same architecture I don't think it is a architecture issue either. I am using OS X 10.6.8 and target Mac OS X 10.4 upwards.
>
> Any insight into this issue is greatly appreciated.
>
> Thanks in advance
> Alex
_______________________________________________
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