views:

292

answers:

3

Hi, I made an Objective-C project for the iPhone. I had only one cpp class, the soundEngine taken from some Apple demo. Now I'm trying to merge OpenFeint which is coded in Objective-C++. I dropped in the code, by simply dragging the files and just tick "Call C++ default ctors/dtors in Objective-C" in Project Settings. I am not even referring to it from my code. When I hit Build, my Objective-C code cannot find the methods of the cpp file. All the class files compile, including OpenFeint's, but in the linking stage it says several of these errors: "_SoundEngine_SetDisabled", referenced from: someClass.o

Note that it is adding an underscore in front of the methods when it's reporting these linking errors.

P.S. I know that for OpenFeint first thing one should do is convert the files to .mm but if possible I don't want to go down that road at this stage of development. I was going to try create a wrapper Objective-C++ class for it. I read someone managed to do that.

A: 

If you're saying you have Objective-C++ files that are not .mm files, then they're not being read as Objective-C++ unless you've done something special to make it so. .mm is the extension for Objective-C++ files. That's why you've been advised to use it.

Chuck
No I'm not saying that. Objective-C++ are .mm, Objective-C are .m and I have one pure C++ file as .cpp. And I cannot access the .cpp methods.
xenonii
Cannot access the C++ methods from *where•? Anywhere? Their own class?
Chuck
Anywhere... compiling works, linking no. And this used to work before I added Objective-C++.
xenonii
Wait, calling a C++ method from Objective-C worked but calling it from Objective-C++ doesn't work?
Chuck
Yes, that's the strange thing. I know its insane. At this point I'm thinking of dumping the cpp class and just use another Audio class from the iPhone framework like AVAudioPlayer
xenonii
A: 

but in the linking stage it says several of these errors: "_SoundEngine_SetDisabled", referenced from: someClass.o

There's no name mangling on that method. Is it declared as extern "C" in a header somewhere but defined as a C++ method/function.

JeremyP
A: 

Hey In that case the files are missing in the target bundle. So clean the build and then rebuild it. Hope this solves the problem.

Praveen