0

I want to call a CPP function from Objective C. I have written the function in CPP. I have tried to call the CPP function from test.mm file, but I am getting following error message.

error: 'functionName' was not declared in this scope

I have written the function 'functionName' in testCPP.cpp & testCPP.h

Please help me to resolve it.

//Objective-C (.mm)
#import "MergeAudios.h"
#import "MergeAudioFiles.h" // cpp header file

@implementation MergeAudios

-(void)mergeAudioFile1:(CFURLRef)path1 file2:(CFURLRef)path2 withFile:(CFURLRef)path3{
    CombineAudioFiles(path1, path2, path3);
}

@end
// CPP (.cpp)

void CombineAudioFiles(CFURLRef sourceURL1, CFURLRef sourceURL2, CFURLRef destinationURL) 
{
......
......
}
4
  • What's in MergeAudioFiles.h? Commented Nov 22, 2010 at 13:53
  • MergeAudioFiles.h is like testCPP.h Commented Nov 22, 2010 at 13:55
  • Yes, but is there a declaration for CombineAudioFiles in MergeAudioFiles.h? If we can't see the code, we can't help. Commented Nov 22, 2010 at 13:57
  • Sorry, In my .cpp file, having 3 methods. I did not declare 'CombineAudioFiles' in .h file. Thank you so much. Commented Nov 22, 2010 at 14:01

1 Answer 1

1

Did you #include "testCPP.h"?

The functions need to be declared in MergeAudioFiles.h, just like in normal C++.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.