[SOLVED] Errors when compiling OgreNewt tutorials on linux

erdem

13-02-2008 20:26:33

I installed OgreNewt and Newton physics engine according to the tutorial in the wiki:

http://www.ogre3d.org/wiki/index.php/Og ... stallation

And I also had a look at the tutorials with Newton Game Dynamics. They compile without any problem.

But when I try to compile the demos in the ogrenewt directory (~/oggreaddons/ogrenewt/demos/Demo01_TheBasics) I get a lot of errors.


g++ -DOGRE_GUI_gtk
-DOGRE_NO_FREEIMAGE -DOGRE_CONFIG_LITTLE_ENDIAN -I/usr/include/OGRE -I/usr/inclu
de/OIS -I/usr/include/ -I /usr/include/OgreNewt/ -lOgreMain -lOIS -lNewton -lOgr
eNewt OgreNewtonApplication.cpp
/usr/lib/gcc/i686-pc-linux-gnu/4.2.2/../../../crt1.o: In function `_start':
(.text+0x18): undefined reference to `main'
/tmp/ccqfbonv.o: In function `OgreNewtonApplication::createFrameListener()':
OgreNewtonApplication.cpp:(.text+0x2d6): undefined reference to `OgreNewtonFrame
Listener::OgreNewtonFrameListener(Ogre::RenderWindow*, Ogre::Camera*, Ogre::Scen
eManager*, OgreNewt::World*, Ogre::SceneNode*)'
OgreNewtonApplication.cpp:(.text+0x339): undefined reference to `OgreNewt::Basic
FrameListener::BasicFrameListener(Ogre::RenderWindow*, Ogre::SceneManager*, Ogre
Newt::World*, int)'
/usr/lib/gcc/i686-pc-linux-gnu/4.2.2/../../../libOgreNewt.so: undefined referenc
e to `NewtonVehicleGetFirstTireID'
/usr/lib/gcc/i686-pc-linux-gnu/4.2.2/../../../libOgreNewt.so: undefined referenc
e to `NewtonUserJointSetRowAcceleration'


Any help would be appreciated. Thank you ..

Game_Ender

13-02-2008 22:06:49

I think you missed the last section:When you use OgreNewt in your project, be sure to link in Newton (-lNewton) *after* OgreNewt, or else your going to get a bunch of undefined function errors.

You have Newton before OgreNewt.

erdem

13-02-2008 23:13:25

Yes I tried this. But I think there is a problem in the OgreNewtonApplication class member function createFrameListener (). or what ? I don't know anything about both Newton and OgreNewt libraries. Finally I managed to compile the first example after commenting this part in the OgreNewtonApplication.cpp:

void OgreNewtonApplication::createFrameListener()
{
mFrameListener = new OgreNewtonFrameListener (mWindow,
mCamera,
mSceneMgr,
m_World,
msnCam );
mRoot->addFrameListener (mFrameListener);


mNewtonListener = new OgreNewt::BasicFrameListener
(mWindow, mSceneMgr, m_World, 120);
mRoot->addFrameListener(mNewtonListener);
}


When I uncomment this part and try to compile the sample (after changing the part you mentioned) like this:

g++ OgreNewtonFrameListener.cpp OgreNewtonApplication.cpp sample.cpp -o sample -DOGRE_GUI_gtk -DOGRE_NO_FREEIMAGE -DOGRE_CONFIG_LITTLE_ENDIAN -I/usr/include/OGRE -I/usr/include/OIS -I/usr/include/ -I /usr/include/OgreNewt/ -I/usr/include/customJoints/ -lOgreMain -lOIS -lOgreNewt -lNewton

It gives linker errors like this:

/tmp/ccCm4Ual.o: In function `OgreNewtonApplication::createFrameListener()':
OgreNewtonApplication.cpp:(.text+0x339): undefined reference to `OgreNewt::BasicFrameListener::BasicFrameListener(Ogre::RenderWindow*, Ogre::SceneManager*, OgreNewt::World*, int)'
Compilation exited abnormally with code 1 at Thu Feb 14 01:07:52


And sample.cpp is a very simple file like this:

#include "OgreNewtonApplication.h"

int main ()
{
OgreNewtonApplication app;
app.go();
}


Thank you for your answer :wink:

erdem

24-02-2008 23:18:01

Ok got it! After getting similiar errors from linker in a project which I study I recognised that OgreNewt_BasicFrameListener.o should also linked. Finally I managed to compile demos in gentoo linux. These are the instructions for demo01.

First of all you should copy the OgreNewt_BasicFrameListener.cpp to demo01 directory like that. And there should be ExampleApplication.h and ExampleFrameListener.h in the same directory. I assume that ogrenewt is installed in home directory:

cp ~/ogreaddons/ogrenewt/OgreNewt_Main/src/OgreNewt_BasicFrameListener.cpp ~/ogreaddons/ogrenewt/demos/Demo01_TheBasics


Than compile source files:

g++ -c OgreNewtonApplication.cpp -o OgreNewtonApplication.o -I/usr/include/OGRE/ -I/usr/include/OgreNewt -I/usr/include/OIS
g++ -c OgreNewtonFrameListener.cpp -o OgreNewtonFrameListener.o -I/usr/include/OGRE/ -I/usr/include/OgreNewt -I/usr/include/OIS
g++ -c OgreNewt_BasicFrameListener.cpp -o OgreNewt_BasicFrameListener.o -I/usr/include/OGRE/ -I/usr/include/OgreNewt -I/usr/include/OIS
g++ -c demo01.cpp -o demo01.o -I/usr/include/OGRE/ -I/usr/include/OgreNewt -I/usr/include/OIS


And finally link them:

g++ demo01.o OgreNewtonFrameListener.o OgreNewtonApplication.o OgreNewt_BasicFrameListener.o -o demo01 -I/usr/include/OGRE/ -I/usr/include/OgreNewt -I/usr/include/OIS -lOgreMain -lOgreNewt -lOIS -lNewton

KennyUK

25-03-2008 20:27:39

Hi,

I had the same problem of the BasicFrameListener class being missing from the libOgreNewt.so. I thought I would investigate by looking at the scons build files. After looking in the SConscript I found the following line:
sources.remove('src/OgreNewt_BasicFrameListener.cpp')
This clearly removed the BasicFrameListener code from the build. After commenting out this line the library rebuilt successfully, and when compiling my application the linker errors had gone.

Surely that line was not meant to be kept in the SConscript file? If so could this change be committed to CVS by someone?

Cheers