I’m trying to use a Cocoa Framework (MultitouchSupport, to be specific) from within a basic Objective-C++ file, but I keep getting undefined symbol errors, as if g++ is supposed to have different linker flags than gcc.
My ultimate goal is to integrate a C++ networking library with some basic Objective-C code I got from here: http://steike.com/code/multitouch/.
When I run this to compile the original code, it works fine:
gcc -F/System/Library/PrivateFrameworks -framework MultitouchSupport test.m -o test -std=c99
But when I rename the file to test.mm, so that it can later include and reference C++ files, the following doesn’t work:
g++ -F/System/Library/PrivateFrameworks -framework MultitouchSupport test.mm -o test
And gives me these errors:
Undefined symbols for architecture x86_64:
"MTDeviceCreateDefault()", referenced from:
_main in ccq0vzuM.o
"MTRegisterContactFrameCallback(void*, int (*)(int, Finger*, int, double, int))", referenced from:
_main in ccq0vzuM.o
"MTDeviceStart(void*, int)", referenced from:
_main in ccq0vzuM.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
make: *** [testpp] Error 1
What do I need to do in order for this Objective-C++ file to see the Framework I’m looking for so I can use C++ with it?
Thanks!
In the header that declares those three functions, is there an
extern "C"block that wraps them? Something like this?If not: You could add one to the header file, or add a similar wrapper around your
#importof that header file.