0

I am new to objective-C, here I develop an iPhone application which contains both C++ and Objective-C files using xcode 5.1. When I try to use the populated value of mytoken from CommunicationHandler.m to CallViewController.mm. I get an error "linker command failed with exit code 1 (use -v to see invocation)". I also try to initialize mytoken with extern but value cannot display at UserToken (CallViewController.mm)*. Please help me to solve my this problem, your help will be highly appreciated. The following are CommunicationHandler.m and CallViewController.mm files with its .h files.

CommunicationHandler.m

// CommunicationHandler.m
#import "CommunicationHandler.h"
...
@implementation CommunicationHandler
NSString* mytoken;
...
-(NSString*) getToken
{
    mytoken=try;
    return mytoken;
}

CommunicationHandler.h

//CommuniationHandler.h
#import <Foundation/Foundation.h>
#import "SecKeyWrapper.h"   

@interface CommunicationHandler : NSObject {
}
...
- (NSString *) getToken;
@end

CallViewController.mm

// CallViewController.mm
#import "CallViewController.h"
...
@implementation CallViewController
...
+(BOOL) makeAudioCallWithRemoteParty:(NSString *)remoteUri andSipStack:(NgnSipStack *)sipStack andtoken:(NSString *)UserToken{

    [sipStack addHeaderName:@"UserToken:" andValue:getToken]; 
    if(![NgnStringUtils isNullOrEmpty:remoteUri]){
        NgnAVSession* audioSession = [[NgnAVSession makeAudioCallWithRemoteParty: remoteUri
                                                                     andSipStack: [[NgnEngine sharedInstance].sipService getSipStack]] retain];
        if(audioSession){
            [idoubs2AppDelegate sharedInstance].audioCallController.sessionId = audioSession.id;
            [[idoubs2AppDelegate sharedInstance].tabBarController presentModalViewController: [idoubs2AppDelegate sharedInstance].audioCallController animated: YES];
            [audioSession release];
            return YES;
        }
    }
    return NO;
}

CallViewController.h

#import <UIKit/UIKit.h>
#import "iOSNgnStack.h"
#import "CommunicationHandler.h"
extern NSString* mytoken;
...
Anil Varghese
  • 42,757
  • 9
  • 93
  • 110
  • possible duplicate of [linker command failed with exit code 1 (use -v to see invocation)](http://stackoverflow.com/questions/10435213/linker-command-failed-with-exit-code-1-use-v-to-see-invocation) Please check if your files are attached to your compiled app. – AlexVogel Aug 06 '14 at 13:10

1 Answers1

0

Try

#ifdef __cplusplus
extern 'C' {
#endif
   extern NSString* mytoken;
#ifdef __cplusplus
}
#endif

If your CallViewController.h header is only included in C++ or Objective-C++ files you can skip the ifdef. `

Lev Landau
  • 788
  • 3
  • 16