tags:

views:

656

answers:

1

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?

Update: Complete Build log: http://dpaste.org/tXAy/

The C++ code:

unzip.h

unzip.cpp

+2  A: 

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++.

freespace
hmm, the .cpp file was already sourcecode.cpp.cpp, the associated header file was .c.h and I updated it to sourcecode.cpp.h but that didn't seem to help any. Any ideas?
Steve918
Hrmph, then perhaps you can try the alternative route, of adding a c++ file via add new file, and just copy-pasting the content?Perhaps your problem is related to linking, are you using any libraries which aren't linked by default?
freespace
Adding the linker flags worked, for some reason I thought xcode did that magic for you depending on what the name of the file was. The is a static lib so maybe that has something to do with it.
Steve918