Code::blocks + Newton & OgreNewt

detox

24-10-2006 15:16:46

Hi everyone,

I have a few very simple questions.

Has there been any success compiling OgreNewt with Codeblocks IDE + gcc compiler under Windows (mingw system)? Is the Newton Game Dynamics SDK useable with gcc? Are there multithreaded versions of the .DLL's in the SDK?

Thanks!

irrdev

27-10-2006 07:01:31

Sure you can compile with C::B. For mingw you will have to of course use the special modified version. I am not sure about multi-threaded dlls... Though why you would want this I am not sure. I would just suggest trying OgreNewt yourself! There is nothing like "hands-on!" :lol:

detox

27-10-2006 18:48:18

I've tried it and had some linking errors. I was hoping there was someone here with experience with codeblocks/mingw and newton.

kartweel

18-11-2006 09:51:18

Hi,

I am also having linking problems. Because the dll wasn't compiled with mingw, it can't link to it like it does with other dlls (eg. how it links to OgreMain.dll). I don't know enough about it to get it to work without linking to it.

I saw in a post someone who said they got it working with some modifications, but he never said what they were.

kartweel

19-11-2006 10:48:22

I have it working. So it can obviously be done. It didn't require any modifications, only setting paths / etc to Newton and Ogre. I produced an OgreNewt dll and link to this from my app. Make sure you include newton when linking in your actual application.

I am using Eclipse and Mingw, but it is the same thing, so should work fine on CB. I am using gcc-4.2.

Narf

20-11-2006 17:01:07

I'm also interested in this. I'd like to have some help about it because i'm new and i have no idea on how to proceed. I searched the forum and the net without success so if someone great and allmighty could give us a hand it would be appreciated.

So, anyone know how to make a dll from those files ?

kartweel

21-11-2006 12:45:16

Here is what I did to compile OgreNewt using mingw.

I had ogre installed at C:\working\OgreSDK
Newton installed at C:\working\NewtonSDK
OgreNewt at C:\working\ogre\ogreaddons\OgreNewt

I used Eclipse CDT. I haven't used Code::Blocks, but it is the same compiler, so it should work the same. You'll just have to find where the settings go.

1. Create a new project for OgreNewt and add the OgreNewt_Main src folder

2. Add to your include paths for the compiler
C:\working\OgreSDK\include
C:\working\NewtonSDK\sdk
C:\working\ogre\ogreaddons\OgreNewt\OgreNewt_Main\inc

3. Add the libraries to the linker
OgreMain Newton

4. Add the library paths to the linker
C:\working\OgreSDK\bin\release (or debug if you are doing a debug build)
C:\working\NewtonSDK\sdk\dll

5. Set the -shared linker flag to make it build a shared library

6. Set the output name to OgreNewt.dll

7. Open the C:\working\NewtonSDK\sdk\Newton.h file and add "#include <stddef.h>" to the very top of it. For some reason when building using gcc it complains of undefined reference to size_t, adding this include fixes it.

8. If you are using this with PLSM2, open the file in your project OgreNewt_CollisionPrimitives.cpp and find the section

//invert vertex winding (otherwise, raycasting won't work???)
poly_verts[0] = vertices[*curIndex]; curIndex++;
poly_verts[2] = vertices[*curIndex]; curIndex++;
poly_verts[1] = vertices[*curIndex]; curIndex++;


and change it to

//invert vertex winding (otherwise, raycasting won't work???)
poly_verts[0] = vertices[*curIndex]; curIndex++;
poly_verts[1] = vertices[*curIndex]; curIndex++;
poly_verts[2] = vertices[*curIndex]; curIndex++;


I found that my objects fell straight through the terrain when using PLSM2 and someone posted this fix on the forums. Turns out it worked. You should probably try it without this first, and if you find things are falling through the terrain, then try it. I guess if you aren't using PLSM2 then you shouldn't have any worries.

Build the project and hopefully you'll end up with an OgreNewt.dll

Then in your project don't forget to include Newton, OgreNewt doesn't remove the dependency on Newton.

Make sure you have Newton.dll and OgreNewt.dll in the same folder as your application.

You might have to mess around a little bit. Most of the time the problem is with paths (make sure paths have double quotes around them for mingw) and if you still have error like (can't find Ogre.h), then try using absolute paths instead of relative paths (ie. c:\ogre\include rather than ..\..\ogre\include)

Don't be tempted to copy files everywhere if your project can't find them, you are much better off getting your include paths right.

Hope this helps out. It covers all the problems I've had along the way.

Narf

21-11-2006 13:59:44

Many thanks to you, i think it will work now.

I was starting to be bored of this thing, now i can start the real work ^^

Anonymous

28-02-2007 02:20:18

The compilation of OgreNewt.dll needs the OIS files...

So I need the libois.a compiled for codeblocks.

Does someone can send me? I did try to make the libois.lib but I'm having many mistakes with directx library.

Thanks

Baiame

14-04-2007 03:59:07

I made a .dll target project in Code::Blocks (using whatever version of Mingw that is required for the Eihort SDK; Ogre works perfectly). Then, I added the OgreNewt .cpp and .h files, and copied the settings regarding directories and libraries from the MSVS project. The project compiles without errors, yet seems to fail to actually output a .dll file. I haven't changed anything else (apart from adding -shared to the linker settings as suggested by kartweel, but I've also tried it without it). Any ideas?

EDIT- I worked out that it's because I was also including the Newton .a library, forgetting that recent Mingw versions don't use such libraries. I excluded that option (leaving just the Newton.dll) and it compiled fine and output a .dll.