Linking in Objective-C
I have a pair of files: Math3d.h and Math3d.cpp that I am trying to import into an iPhone project. The math functions are for use with OpenGL ES.
These files are not a class. The .h contains mostly inline functions and some function declarations that are defined in the .cpp counterpart.
I am having a problem getting this to link. If nothing references any function in these files, it compiles just fine. It's when I try to use one of the function, it acts like it doesn't know what to do.
I am #include ing the file where I need to use it and I'm #ifndef ... #define ... #endif ing the .h to prevent multiple includes.
This file was taken directly from a C++ project that was working perfectly. Can somebody please tell me what I have to do to reference a static function in Objective C? Tell me it doesn't have to be part of a class just to reference a function. Thanks.
These files are not a class. The .h contains mostly inline functions and some function declarations that are defined in the .cpp counterpart.
I am having a problem getting this to link. If nothing references any function in these files, it compiles just fine. It's when I try to use one of the function, it acts like it doesn't know what to do.
I am #include ing the file where I need to use it and I'm #ifndef ... #define ... #endif ing the .h to prevent multiple includes.
This file was taken directly from a C++ project that was working perfectly. Can somebody please tell me what I have to do to reference a static function in Objective C? Tell me it doesn't have to be part of a class just to reference a function. Thanks.
Mixing (Obj)C and (Obj)C++ you've likely hit name mangling.
http://en.wikipedia.org/wiki/Name_mangli...in_C.2B.2B
http://en.wikipedia.org/wiki/Name_mangli...om_C.2B.2B
http://en.wikipedia.org/wiki/Name_mangli...in_C.2B.2B
http://en.wikipedia.org/wiki/Name_mangli...om_C.2B.2B
I actually fixed this by putting
before every inline function.
Code:
static
