Compiling Box2D with g++

johanp
Posts: 3
Joined: Wed Feb 21, 2007 9:39 pm

Compiling Box2D with g++

Post by johanp »

Hello,

after trying out several physics libraries, tutorials and similar engines I stumbled on Box2D which more or less seems to do exactly what I need.

However, I'm using g++ and it doesn't want to compile. I get three errors (of the same kind):

Code: Select all

passing 'const Arbiter' as 'this' argument of 'void Arbiter::Update(Contact*, int)' discards qualifiers
One of them takes place in World::BroadPhase() and the other two in World::Step(...).

Now, I did some research and I wasn't the first to run into this problem. On a blog (gbgames . com / blog/?p=444) a solution was offered for the two occations in World::Step , but that solution isn't applicable to the the first error.

In short, the line that's giving me problems is this one: (should be line 63 in World.cpp)

Code: Select all

(*arb).Update(newArb.contacts, newArb.numContacts);
The other cases were solved like this:

Code: Select all

        // new code from that blog
        ArbIter arb = arbiters.begin();
        while (arb != arbiters.end())
        {
            // Erase key from set, modify it, then add it again.
            Arbiter newArb((*arb).body1, (*arb).body2);
            newArb.ApplyImpulse();
            arbiters.erase(arb++);
            arbiters.insert(newArb);
        }

        /* old code
		for (ArbIter arb = arbiters.begin(); arb != arbiters.end(); ++arb)
		{
			(*arb).ApplyImpulse();
		}
		*/
I know this is more a c++ issue than a physics issue, but I partly figured you might be aware of this problem and have a solution.

Thank you in advance!

ps. I tried to post a link to that blog but your spam filter said no. :)
Erin Catto
Posts: 316
Joined: Fri Jul 01, 2005 5:29 am
Location: Irvine

Post by Erin Catto »

Thanks johanp.

I've fixed these issues for GDC'07. I'll probably ditch the std::set usage eventually.
johanp
Posts: 3
Joined: Wed Feb 21, 2007 9:39 pm

Post by johanp »

Thanks for the quick answer Erin. I scouted around some more and found an edit of your code which was g++ compatible.

As for your GDC'07 version, I guess I'll have to wait until after GDC'07 to get my hands on it? :wink:
crashlander
Posts: 41
Joined: Sat Apr 08, 2006 11:20 am

Post by crashlander »

When do you think you will be releasing your GDC 07 version? Want to give any hints as to what has changed?
Erin Catto
Posts: 316
Joined: Fri Jul 01, 2005 5:29 am
Location: Irvine

Post by Erin Catto »

There are no big additions yet. You can now download it here:

http://www.gphysics.com/files/GDC2007_ErinCatto.zip

The presentation changed this year, so you might find it interesting.
johanp
Posts: 3
Joined: Wed Feb 21, 2007 9:39 pm

Post by johanp »

Thanks for letting me know! I'll check it out right away.