ODE Problems

Geppy
Unregistered
 
Post: #1
I've downloaded ODE, built it, and put it in the correct locations. Now I'm ready to use it in my C++ Xcode project but when i simply include it (as in #include <ode/ode.h>) Xcode chokes on this:

Code:
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

What's that about??? Did I do something wrong? I've been looking but can't find any answers. Thanks!
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #2
Did you download the official 0.5 release? Or did you get it from CVS?

I've had *bad* luck with ODE CVS in the past -- it's best to go with the official build.
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #3
That looks like you're including the ODE headers in a .cpp file, which will break the linkage to hell. Bracket your inclusion of the ode headers with
Code:
extern "C"
{
    // Add your headers here
    #include "ode.h"
}
Quote this message in a reply
Geppy
Unregistered
 
Post: #4
I'm using the official v0.5 release. And before I built i changed the user-settings file so that "PLATFORM=osx". Everything built without error. I copied the contents of ode-0.5/lib/ to /usr/lib/ and the contents of ode-0.5/include to /usr/include/

Is that correct? Maybe I'm not setting up my Xcode project correctly? I thought all i had to do was include <ode/ode.h> and i'd be set. Do i have to add anything to the project?

I tried using the
Code:
extern "C"
{
#include "ode.h"
}

but that didn't work. If i do it that way i have to add "/usr/include/ode/" as a header search path for my project. So I added that and then got the same errors from my first post!

HELP!! Huh
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #5
Try:
Code:
extern "C"
{
#include <ode.h> // <-- note the brackets, not quotes
}

edit: also remove that search path you added... Smile
Quote this message in a reply
Geppy
Unregistered
 
Post: #6
Hey thanks for the quick reply Fenris!

I tried that (using #include <ode.h> instead of "ode.h") and if just says "ode.h: No such file or directory".....

And if i try #include <ode/ode.h> inside of the extern "C" brackets i just get those original errors again. This is really puzzling to me. Surely it can't be that hard to get this working....
Annoyed
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #7
Hm, I haven't used ODE myself, so excuse me if this question is obvious: is this a framework, a shared library or what?

And NP, by he way, I'm just relieved other people have non-working code. Wink
Quote this message in a reply
Geppy
Unregistered
 
Post: #8
ODE is the Open Dynamics Engine ( http://www.ode.org ). Its basically a physics engine that is very portable. Unfortunately the documentation online is a little lacking regarding getting it running on OS X.
Quote this message in a reply
Oldtimer
Posts: 832
Joined: 2002.09
Post: #9
Ah, yes, I know that much. Wink I'm just wondering what the "format" of it is a framework, or a shared library or what. How did you compile it? Command-line, XCode...? (Or, give me a URL to the source, and I'll look myself if you don't know) Smile
Quote this message in a reply
Member
Posts: 144
Joined: 2004.07
Post: #10
Static library is by default what the makefile creates.

Are you maybe not using extern in the right file(s)?
That _should_ work.
Quote this message in a reply
Geppy
Unregistered
 
Post: #11
The version i'm using can be downloaded here .

It builds a library that I then move to /usr/lib/

I assume I also need to add that built library (libode.a) to my project?
Quote this message in a reply
Sage
Posts: 1,199
Joined: 2004.10
Post: #12
This is really weird. I've never seen any troubles like that. You *should* be able to include <ode/ode.h> from anywhere, without bracketing.

My personal setup doesn't involve copying ode to /usr -- I keep a local copy of the lib and the headers in a file structure such as:

Code:
ProjectRoot/
    include/
        ode/
        freetype/
        etc...

    lib/
        libode.a
        libfreetype.a
        etc...

And then in my build settings I add include/ to the header search path. The headers themselves are unmodified.

In case you're wondering why I take this approach, it's to make it easier to work on difference machines without having to muck around in usr/ -- plus, it makes it easier to use different versions of libs in different projects.

Anyway, this works for me...
Quote this message in a reply
Member
Posts: 184
Joined: 2004.07
Post: #13
It sounds like the opposite of the extern "C" problem- somewhere the ode include is in an extern "C" block when it shouldn't. The reason why I suspect this is that the first problem in question- "declaration of C function `double dDISTANCE... "- is supposed to be compiled in C++, so that the two dDISTANCE functions will have different signatures, and the second problem in question about "template with C linkage" means that the compiler is trying to compile C code, but it found the template keyword.

ODE actually does take advantage of some C++ features, which is where this problem is coming from. Provided the library has been compiled with C++, you don' t need the extern "C" block around the include.

So possibly we should see how you are including the .h files (so, your source code where you include ode), and also what the compile string is (what arguments to g++ is XCode trying to use?)
Quote this message in a reply
Geppy
Unregistered
 
Post: #14
First of all, thank you to everyone for all the help!

My project has a fairly complex structure because it includes a lot of files and makes use of a precompiled prefix header. Rather than post a bunch of code that is very likely not the cause of my problems I made a new test project for you to look at. All I did was start a new project in Xcode using "New Project..." --> "C++ Tool". Then I simply changed the automatically created main.cpp file to read as this:
Code:
#include <ode/ode.h>

#include <iostream>
using namespace std;



int main (int argc, char * const argv[])
{
    // insert code here...
    cout << "Hello, World!" << endl;
    
    return 0;
}

That's all it takes to generate the exact same errors as my first post. If you want I can post this sample project. Am i just being stupid and doing something wrong?
Quote this message in a reply
Sage
Posts: 1,066
Joined: 2004.07
Post: #15
I'm having similar problems and am not even sure I'm doing any of the setup/installation right. Can someone here quick type up brief tutorial on 'installing' and using ODE (just to the extent of including it, not necessarily how to do anything)? That would help a lot. Thanks.
Quote this message in a reply
Post Reply