C++ – linking c++ sources in iPhone project

ciphonelinker

I have a single cpp file added to my iPhone project with a .cpp extension, but I'm seeing errors when linking like:

operator new[](unsigned long)", referenced from:

___gxx_personality_sj0", referenced from:

I thought as long as I named the cpp files with .cpp or .mm it would do the right thing, do I need to add some linker flags?

Best Answer

Select the file in the project browser, and press cmd-i to bring up the info window for the file in question. Set File Type to sourcecode.cpp.cpp should do it.

Alternatively right click on your project, add new file, select C++ source, then copy and paste the content.

In light of the build log, try adding the following linker flags:

-cclib -lstdc++

This might be because gcc is being used to link, not g++.