View Full Version : ODE w/ Cocoa
hangt5
2005.03.22, 10:05 PM
I downloaded, compiled, and installed ODE (successfully) and did a few fun little carbon tests. I now, really really want to incorporate it into my (cocoa based) game. I saw that someone made a 'Cocoa port' a while back, but apparently its not up to date. Is there a way to get the normal up to date version of ODE working in a cocoa application?... Short of porting it that is.
Why wouldn't it work in a Cocoa app? Isn't it C?
hangt5
2005.03.22, 11:01 PM
I get Zerolink: unknown symbol errors in my cocoa app, and it runs perfectly in my carbon app. If i make the cocoa file obj-c++ i get a bunch of errors: "Template with C Linkage", "Undefined Type ID, please import objc/objc.h", "/usr/include/ode/odemath.h:122: error: declaration of C function `double dDISTANCE(const double*, const double*)' conflicts with
"...etc
EDIT: apparently im getting all the same errors as this Thread (http://www.idevgames.com/forum/showthread.php?t=8745). The fix at the end of the thread didnt work...
EDIT2: its c++
TomorrowPlusX
2005.03.23, 12:45 PM
Hey, I made the "Cocoa port" -- all it was was ODE built to a framework, and an implementation of drawstuff which was GLUT happy. The thing is, after I submitted some patches to get clean building on OS X, maintaining a build was unecessary. So just build it from the command line and you're gold.
Now, regarding calling ODE from ObjC -- DON'T. ODE's headers have *many* function parameters and variables named "id", which is a reserved keyword in ObjC.
If you want to use Cocoa for your frontend ( I do, for example ) you'll need to be careful regarding what you expose. You can, basically, get away with having your interface include <ode/common.h> which is ObjC friendly, and your implementation include <ode/ode.h>
This works, so long as you're not using dGeomTrimesh. That requires includes which aren't ObjC friendly. You'll have to make an abstraction layer if you want to do that.
hangt5
2005.03.23, 01:14 PM
Cool. Thanks a lot for the information, and the bug reports.
hangt5
2005.03.23, 01:30 PM
I get the same errors/linker errors. :mad:
In Obj-C i get at runtime "ZeroLink: unknown symbol '___cxa_pure_virtual'."
And in Obj-C++ i get these compiling errors.
In file included from /usr/include/ode/ode.h:34,
from /Users/bobsmith/ODETest3/ODETest3View.mm:2:
/usr/include/ode/odemath.h: In function `double dDISTANCE(const double*, const double*)':
/usr/include/ode/odemath.h:122: error: declaration of C function `double dDISTANCE(const double*, const double*)' conflicts with
/usr/include/ode/odemath.h:120: error: previous declaration `float dDISTANCE(const float*, const float*)' here
/usr/include/ode/odemath.h: At global scope:
/usr/include/ode/odemath.h:180: error: template with C linkage
/usr/include/ode/odemath.h:181: error: template with C linkage
/usr/include/ode/odemath.h:182: error: template with C linkage
/usr/include/ode/odemath.h:183: error: template with C linkage
/usr/include/ode/odemath.h:184: error: template with C linkage
/usr/include/ode/odemath.h:185: error: template with C linkage
/usr/include/ode/odemath.h:187: error: template with C linkage
/usr/include/ode/odemath.h:188: error: template with C linkage
/usr/include/ode/odemath.h:189: error: template with C linkage
/usr/include/ode/odemath.h:190: error: template with C linkage
/usr/include/ode/odemath.h:191: error: template with C linkage
/usr/include/ode/odemath.h:192: error: template with C linkage
In file included from /usr/include/ode/ode.h:44,
from /Users/bobsmith/ODETest3/ODETest3View.mm:2:
/usr/include/ode/odecpp_collision.h: In member function `void dSpace::setCleanup(int)':
/usr/include/ode/odecpp_collision.h:133: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h: In member function `int dSpace::getCleanup()':
/usr/include/ode/odecpp_collision.h:135: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h: In member function `void dSpace::add(dxGeom*)':
/usr/include/ode/odecpp_collision.h:138: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h: In member function `void dSpace::remove(dxGeom*)':
/usr/include/ode/odecpp_collision.h:140: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h: In member function `int dSpace::query(dxGeom*)':
/usr/include/ode/odecpp_collision.h:142: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h: In member function `int dSpace::getNumGeoms()':
/usr/include/ode/odecpp_collision.h:145: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h: In member function `dxGeom* dSpace::getGeom(int)':
/usr/include/ode/odecpp_collision.h:147: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h: In member function `void dSpace::collide(void*, void (*)(void*, dxGeom*, dxGeom*))':
/usr/include/ode/odecpp_collision.h:150: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h: In member function `void dHashSpace::setLevels(int, int)':
/usr/include/ode/odecpp_collision.h:174: error: undefined type `id', please import <objc/objc.h>
/Users/bobsmith/ODETest3/ODETest3View.mm: In function `objc_object* -[ODETest3View initWithFrame:](ODETest3View*, objc_selector*, _NSRect)':
/Users/bobsmith/ODETest3/ODETest3View.mm:12: error: cannot convert `double' to `NSOpenGLPixelFormatAttribute' in initialization
/Users/bobsmith/ODETest3/ODETest3View.mm: In function `void -[ODETest3View awakeFromNib](ODETest3View*, objc_selector*)':
/Users/bobsmith/ODETest3/ODETest3View.mm:65: error: assignment of function `time_t time(time_t*)'
/Users/bobsmith/ODETest3/ODETest3View.mm:65: error: cannot convert `objc_object*' to `time_t ()(time_t*)' in assignment
/Users/bobsmith/ODETest3/ODETest3View.mm:66: error: cannot convert `time_t (*)(time_t*)' to `NSTimer*' in argument passing
/Users/bobsmith/ODETest3/ODETest3View.mm:67: error: cannot convert `time_t (*)(time_t*)' to `NSTimer*' in argument passing
/Users/bobsmith/ODETest3/ODETest3View.mm: In function `void -[ODETest3View reshape](ODETest3View*, objc_selector*)':
/Users/bobsmith/ODETest3/ODETest3View.mm:79: warning: passing `float' for argument passing 3 of `void glViewport(long int, long int, long int, long int)'
/Users/bobsmith/ODETest3/ODETest3View.mm:79: warning: argument to `long int' from `float'
/Users/bobsmith/ODETest3/ODETest3View.mm:79: warning: passing `float' for argument passing 4 of `void glViewport(long int, long int, long int, long int)'
/Users/bobsmith/ODETest3/ODETest3View.mm:79: warning: argument to `long int' from `float'
from /Users/bobsmith/ODETest3/ODETest3View.mm:2:
In file included from /usr/include/ode/ode.h:34,
/usr/include/ode/odemath.h:122: error: declaration of C function `double dDISTANCE(const double*, const double*)' conflicts with
/usr/include/ode/odemath.h:120: error: previous declaration `float dDISTANCE(const float*, const float*)' here
/usr/include/ode/odemath.h:180: error: template with C linkage
/usr/include/ode/odemath.h:181: error: template with C linkage
/usr/include/ode/odemath.h:182: error: template with C linkage
/usr/include/ode/odemath.h:183: error: template with C linkage
/usr/include/ode/odemath.h:184: error: template with C linkage
/usr/include/ode/odemath.h:185: error: template with C linkage
/usr/include/ode/odemath.h:187: error: template with C linkage
/usr/include/ode/odemath.h:188: error: template with C linkage
/usr/include/ode/odemath.h:189: error: template with C linkage
/usr/include/ode/odemath.h:190: error: template with C linkage
/usr/include/ode/odemath.h:191: error: template with C linkage
/usr/include/ode/odemath.h:192: error: template with C linkage
from /Users/bobsmith/ODETest3/ODETest3View.mm:2:
In file included from /usr/include/ode/ode.h:44,
/usr/include/ode/odecpp_collision.h:133: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h:135: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h:138: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h:140: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h:142: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h:145: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h:147: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h:150: error: undefined type `id', please import <objc/objc.h>
/usr/include/ode/odecpp_collision.h:174: error: undefined type `id', please import <objc/objc.h>
/Users/bobsmith/ODETest3/ODETest3View.mm:12: error: cannot convert `double' to `NSOpenGLPixelFormatAttribute' in initialization
/Users/bobsmith/ODETest3/ODETest3View.mm:65: error: assignment of function `time_t time(time_t*)'
/Users/bobsmith/ODETest3/ODETest3View.mm:65: error: cannot convert `objc_object*' to `time_t ()(time_t*)' in assignment
/Users/bobsmith/ODETest3/ODETest3View.mm:66: error: cannot convert `time_t (*)(time_t*)' to `NSTimer*' in argument passing
/Users/bobsmith/ODETest3/ODETest3View.mm:67: error: cannot convert `time_t (*)(time_t*)' to `NSTimer*' in argument passing
/Users/bobsmith/ODETest3/ODETest3View.mm:79: warning: passing `float' for argument passing 3 of `void glViewport(long int, long int, long int, long int)'
/Users/bobsmith/ODETest3/ODETest3View.mm:79: warning: argument to `long int' from `float'
/Users/bobsmith/ODETest3/ODETest3View.mm:79: warning: passing `float' for argument passing 4 of `void glViewport(long int, long int, long int, long int)'
/Users/bobsmith/ODETest3/ODETest3View.mm:79: warning: argument to `long int' from `float'
In my .h i included <ode/common.> and in my .m(m) i included <ode/ode.h>
hangt5
2005.03.23, 05:57 PM
I fixed this by including libstdc++.a in my project.
TomorrowPlusX
2005.03.24, 07:49 AM
Excellent! I've seen a couple posts with similar ODE problems here lately, and now there's an answer that can be given to those who see it.
For what it's worth, ODE is actually C++ on the inside. But it's wrapped in C. ODE's C interface is robust and reliable across releases, but the internal C++ changes a lot.
It's a little hoary, but it does the job. Makes me feel funny, though, writing an ODE C++ wrapper around C which wraps C++ :P
Duane
2005.03.24, 03:00 PM
how is a C wrapper around C++ possible?
how is a C wrapper around C++ possible?
Sure, it's possible. I don't really see a point to it, and it causes confusion when you have to do things like link to libstdc++.a... but it's possible.
Duane
2005.03.27, 11:55 AM
I thought that C didn't really recognize that C++ existed?
wadesworld
2005.03.27, 02:47 PM
Nayr,
Trying to use a native C++ interface for a library opens up a host of C++ compatibility issues, and that's why 99% of libraries will expose a C interface only, even though the implementation may be in C++.
Wade
vBulletin® v3.6.8, Copyright ©2000-2008, Jelsoft Enterprises Ltd.