nww02
02-10-2011 23:08:10
For the last few days, I've been wrestling with getting the right sets of incantations to make Ogre, Newton and OgreNewt all work. For someone who's not primarily a C++ developer, like me, this can be quite daunting. The error messages, while moderately helpful don't include a "Now, do X", to help you fix it.
Anyway, here is the set of steps I took using the absolutely Vanilla downloads of Ogre, Newton and OgreNewt, to get a working trio of libraries. Your Mileage may vary. It's entirely possible I've missed a step, so if anyone finds a problem, post the fix.
Get The Sources
Anyway, here is the set of steps I took using the absolutely Vanilla downloads of Ogre, Newton and OgreNewt, to get a working trio of libraries. Your Mileage may vary. It's entirely possible I've missed a step, so if anyone finds a problem, post the fix.
Get The Sources
- Use Visual Studio 2008. I kept running into problems with VS2010, and as soon as I ditched it for 2008, everything started clicking into place.
[/*:m]
- Download Newton Game Dynamics, and unpack into a folder, for example:
D:\DEVELOPMENT\newton-dynamics-2.33
[/*:m]
- Download OGRE: I suggest the VC2008 version. Unpack into a folder, for example:
D:\DEVELOPMENT\OGRE
This will generate a subfolder under this folder with the name/compiler/release of the sdk. Right now, that is OgreSDK_vc9_v1-7-2
[/*:m]
- Download OgreNewt, and unpack into a folder, for example:
D:\DEVELOPMENT\OGRENewt
Sadly, although you can download it one file at a time using the above link, to get it all at once you'll need an SVN client. TortoiseSVN is my favourite.
- Download and install TortoiseSVN[/*:m]
- Create a subfolder of your dev folder called OgreNewt[/*:m]
- Right-click the folder and choose 'Check Out'[/*:m]
- Enter the URL for the Ogre-Addons Repo http://svn.ogre3d.org/svnroot/ogreaddons/branches/ogrenewt/newton20[/*:m]
- Click OK, and sit back as OgreNewt2.0 is brought to you.[/*:m][/list:u][/*:m][/list:u]
Set Up some Env. Variables
Now, add some 'HOME' variables. You don't have to do this, but it makes things easier:
- Right-click on My Computer, and select Properties. [/*:m]
- Under the advanced tab, select "Environment Variables"[/*:m]
- In the window which pops up, click "New", then add the following Variables:
BOOST_HOME D:\DEVELOPMENT\ogre\OgreSDK_vc9_v1-7-2\boost_1_44
NEWTON_HOME D:\DEVELOPMENT\newton-dynamics-2.33
OGRE_HOME D:\DEVELOPMENT\OGRE\OgreSDK_vc9_v1-7-2
OGRENEWT_HOME D:\DEVELOPMENT\OgreNewt[/*:m][/list:u]
The reason why 'Ogre' is an extra level deep is that because you may want to have several ogre versions eventually, and when you unzip the distro, it adds the SDK foldername.
Build Newton
Newton comes with a precompiled library, but it's missing dmath, which you'll need for OgreNewt. Go into the Newton folders and find the packages\projects\visualstudio_2008 folder
- Double-click on build.sln
[/*:m]
- Build the newton packages using all four configurations, Debug, DebugDLL, Release, ReleaseDLL
[/*:m]
- Go to the packages\win32\debug folder and copy the dmath_d.lib, dScene_d.lib, tinyxml_d.lib and dContainers_d.lib into the packages\win32\debugDll folder. Don't copy the newton_d.lib and dJointLibrary_d.lib over the ones already created.
[/*:m]
- Go to the packages\win32\release folder and copy the dmath.lib, dscene.lib, tinyxml.lib and dContainers.lib into the packages\win32\releaseDll folder. Don't copy the newton.lib and dJointLibrary.lib over the ones already created.[/*:m][/list:u]
OK, now you've got Newton all compiled and the dmath libraries all compiled up and in one place. Excellent. Now, it's time to compile OgreNewt.
Build OgreNewt
Go into the OgreNewt folder, and open the OgreNewt_VS9.sln file. bring up the OgreNewt project's property page by right-clicking on it, and locate the C/C++ \ General panel. Open up the Additional Include Directories and delete all the entries, replacing them with:-
$(OGRE_HOME)\include\OGRE
$(OGRENEWT_HOME)\inc
$(BOOST_HOME)
$(NEWTON_HOME)\packages
$(NEWTON_HOME)\packages\dCustomJoints
$(NEWTON_HOME)\packages\dMath
Now open up Linker\General, and open the Additional Library Directories. Remove all the ones there, and replace them with (for the debug configuration) :-
$(OGRE_HOME)\lib\debug
$(NEWTON_HOME)\Packages\Win32\debugDLL
$(BOOST_HOME)\lib
OKay, now you need to ensure that all the libraries you need are listed. So head to Linker\Input and make sure the Additional Dependencies are (at least):-
ogremain_d.lib
newton_d.lib
dJointLibrary_d.lib
ogreterrain_d.lib
dmath_d.lib
- Under C/C++ Code Generation, ensure you've chosen "Multi-Threaded Debug DLL (/MDd)".
[/*:m]
- Under Build Events\Post-Build Step, you may find some Copy instructions. Best to remove them. They tend to break.
[/*:m]
- Lastly, open C/C++ \ Command Line, and add /Zm133 into the additional options.
[/*:m]
- Okay, hit 'Build', and finger-crossed, OgreNewt should build with the latest Ogre (1.7.2) and Newton (2.33) releases.[/*:m][/list:u]
If it worked, yay, now change the Project configuration for the "Release" configuration. Do all the same stuff for the debug Configuration, but take out the "_d" from the ends of library names, and change 'Debug' for 'Release' in the directory names. If it didn't work, then sorry, you're outta luck: Something must have changed, you've got your home folders not quite right, or I've goofed a step.
Note: if you change an environment variable, you gotta close visual Studio and re-open it for the change to get picked up. Keep at it.
Errors you may get when compiling OgreNewt
- Anything with (dllimport) in it means you're missing a library somewhere. Probably dmath_d.lib, or dJointLibrary_d.lib. Make sure you do the build Newton steps.[/*:m]
- Anything mentioning libboost_thread-vc90-mt-sgd-1_44 (NOTE: SGD) means you're trying to compile the library as a statically linked library. You *can* get the static version of the boost library if you hunt about, but it's best to just stick to making all your libs as DLLs. if it's just "GD", then you've not included the boost lib directory under 'Linker'.[/*:m]
- Anything saying that a symbol is already defined. uh oh, you're in the eternal trap of different compilation types. It means that two of your libraries are statically linked, and they both include a third one. When the project tries to import the second library, it finds all the symbols from the third already imported with the first! Eek. Either make sure you build the parent libs as DLLs, or only statically include one of them. This one can be a pain to debug for the novice.[/*:m]
- Anything saying you've got conflicting default libs. For the most part these warnings can be ignored. But if you have lots of these, and they're errors, it means that you've got two libraries trying to include two different versions of a third library. This is usually because one is static, the other dynamic. Usually this is the default windows C runtime libraries (the ones every project needs). To fix it, you'll have to make sure all your libraries, and your main project build the same way.[/*:m]
- You get a request for /Zmxxx. This is a strange one. Just go the C/C++ Command Line Additional Options box in the project, and pop in the suggested line. I used /Zm133 because it worked for me. You may need higher or lower.[/*:m][/list:u]
You're all set.
Create your new project, use the same include and library folders as mentioned above, but [important] remember to copy all the DLLs from Ogre\bin, Ogrenewt\lib and newton\packages\win32 to your project build output folder! without the DLLs in the same place as where your .exe gets compiled to, you'll end up with lots of dllimport errors. Why not create an empty project, all ready to go, and use it as a template for all your experiments?
Good Luck!!
Disclaimer: I am not an expert, I'm not a C++ guru, and I've been playing with Ogre and Newton for a grand total of a week. However, I managed to get it compiled, but couldn't find all of this information in one place, so thought it may help to put it all together. I apologise unreservedly if any of this is wrong. I know that there's probably much easier ways to do this, and I've probably broken some convention somewhere, but I now have working physics, so hey, I'm happy
- Anything with (dllimport) in it means you're missing a library somewhere. Probably dmath_d.lib, or dJointLibrary_d.lib. Make sure you do the build Newton steps.[/*:m]
- Under C/C++ Code Generation, ensure you've chosen "Multi-Threaded Debug DLL (/MDd)".
- Double-click on build.sln
- Right-click on My Computer, and select Properties. [/*:m]
- Download and install TortoiseSVN[/*:m]