Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

ta3ban4

macrumors newbie
Original poster
Dec 23, 2009
5
0
Hi All ,
I'm fairly new to Iphone development. I created View based application and copied C ++ class that i have created a while back to use. First i did drag my h/cpp files to the Classes folder. Changed MyViewController.m File Type to soucecode.cpp.objcpp then #include "eCharBuffer" it compiles fine , but when i try to instantiate/creat an object eCharBuffer mybuff (100,true); it give me the following error ;

Undefined symbols:
"eCharBuffer::eCharBuffer(bool)", referenced from:
-[MapViewController .cxx_construct] in MapViewController.o
"eCharBuffer::~eCharBuffer()", referenced from:
-[MapViewController .cxx_destruct] in MapViewController.o

Unless i define it as a pointer eCharBuffer *mybuff which i dont want to use.

Any Idea Why and how i can fix . I have a lot of C++ code that i dont want to port to Objective C

Thanks In Advace
 
Try changing your file extension. Objective-C++ files use the extension "mm", not "cpp" or "objcpp".

I have changed eCharBuffer.cpp to .mm also the class MapViewController.m to .mm . Still getting the same Error

Thanks
 
I have changed eCharBuffer.cpp to .mm also the class MapViewController.m to .mm . Still getting the same Error

Thanks

Change ALL .m files to .mm. Even those who don't appear to have a C++ class or file included.
 
I would double check your code and make sure you are actually implementing the two methods you are referencing. Also make sure that your "eCharBuffer.cpp" is being included in the compilation
 
There is a build setting called 'Call C++ Default Ctors/Dtors in ObjectiveC' that you may need to be turned on.

Is your c++ class that is causing the problem an ivar of an Obj-C class or are you allocating it on the stack?
 
I have been looking at Xcode Build System doc on Apple Dev site made me a but more confused. I did set " Call C++ Default Ctors/Dtors in ObjectiveC" under build/code generation with no success . Not sure what "ivar of an Obj-C class or are you allocating it on the stack" . I'm attaching the h/mm"cpp" files a simple byte buffer class.

Thanks for the help Guys
 

Attachments

  • Archive.zip
    2.6 KB · Views: 72
"ivar of an Obj-C class or are you allocating it on the stack"

This line

eCharBuffer mybuff (100,true);

Is an object of your c++ class an instance variable of an Objective-C class?

Are you allocating an instance of your c++ class on the stack?
 
This line



>>Is an object of your c++ class an instance variable of an Objective-C class?
>>Are you allocating an instance of your c++ class on the stack?

Simply an instance variable of eCharBuff class , which when i tried to initialize in my MapViewController.m class ,myBuff (100, true) was giving me the that error. I tried eCharBuff *mybuff and it did compile. Hope that did help

Thanks
Merry Christmas everyone :)
 
i got it to compile when using eCharBuff *mybuff , but im getting the following warning
warning: no rule to process file warning: no rule to process file '$(PROJECT_DIR)/Classes/eCharBuffer.mm' of type sourcecode.cpp for architecture i386




Any idea ,
Thanks for the help
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.