Can someone compile this for me?
Can someone compile this for me?
Can someone please attempt to compile my project under Windows with MingW? Its been dead for over a month now, because my executables generate seg faults. I think its my compiler settings, or the libraries I'm linking with. But after a month of tweaking and no results, I think compiling on a whole other computer may work.
Heres the link to my previous thread - http://irrlicht.sourceforge.net/phpBB2/ ... highlight=
It does compile, but the generated executables crash at startup. And yes, I have debugged it. All that info is in my previous thread. If anyone is willing to try on their computer, I'll upload a zip with the source and other files.
Thanks in advance =]
Heres the link to my previous thread - http://irrlicht.sourceforge.net/phpBB2/ ... highlight=
It does compile, but the generated executables crash at startup. And yes, I have debugged it. All that info is in my previous thread. If anyone is willing to try on their computer, I'll upload a zip with the source and other files.
Thanks in advance =]
Last edited by Buck1000 on Sun Feb 07, 2010 7:30 pm, edited 1 time in total.
-
- Admin
- Posts: 14143
- Joined: Wed Apr 19, 2006 9:20 pm
- Location: Oldenburg(Oldb), Germany
- Contact:
What did the bullet forum say? And what further debugging attempts did you make? Maybe instrument the destructors to tell you when they are called, or set some watchpoints to test the pointers on given conditions. And are you sure that your dlls are all working together correctly? Did you recompile them on your own, or do you use precompiled ones?
They didn't offer much advice, other than saying that CodeBlocks doesn't auto-initialize variables to 0, but MSVC++. I had already checked for that though.
As to my attempts, I've tried compiling with different compiler optimizations and flags turned off/on, and it always generates a seg fault when run. I've commented various lines out, but the situation literally remains as it did a month ago. I had to compile my own dlls, because Bullet requires the developer to compile them anyway, and I did the same for Irrlicht. Maybe I need to use the "Fast FPU" build option? I haven't tried that yet.
And, I don't see how removeCollisionObject() can be called from stepSimulation() in the first place. I've started another thread on the Bullet forums asking about that, and they may be able to fill me in. My geuss is that the pointer to my rigid body in that list is bad, and the bullet world automatically deletes everything. But, the crash happens after the call to removeCollisionObject(). Shouldn't it crash before, if the pointer is bad? I don't know how to check for bad pointers in CB. I assumed they're fine, since the exact same code works great in MSVC++. I'll google that, and try it next.
As to my attempts, I've tried compiling with different compiler optimizations and flags turned off/on, and it always generates a seg fault when run. I've commented various lines out, but the situation literally remains as it did a month ago. I had to compile my own dlls, because Bullet requires the developer to compile them anyway, and I did the same for Irrlicht. Maybe I need to use the "Fast FPU" build option? I haven't tried that yet.
And, I don't see how removeCollisionObject() can be called from stepSimulation() in the first place. I've started another thread on the Bullet forums asking about that, and they may be able to fill me in. My geuss is that the pointer to my rigid body in that list is bad, and the bullet world automatically deletes everything. But, the crash happens after the call to removeCollisionObject(). Shouldn't it crash before, if the pointer is bad? I don't know how to check for bad pointers in CB. I assumed they're fine, since the exact same code works great in MSVC++. I'll google that, and try it next.
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Reading your previous thread, you don't need someone to compile your app, but to debug it. There's obviously something wrong with your code.
Please post the whole UpdatePhysics() function from physics.cpp.
And another thing
I would bullet let do this automatically. MotionsStates are there for a reason.
Please post the whole UpdatePhysics() function from physics.cpp.
And another thing
Code: Select all
for(list<btRigidBody *>::Iterator Iterator = Physics->Objects.begin(); Iterator != Physics->Objects.end(); ++Iterator)
{
UpdateRender(*Iterator, Physics);
}
"Whoops..."
My code is fine, and I have debugged it. I gave all that info in the other thread.
As I said before, it all runs fine if compiled from MSVC++ 2008.
UpdatePhysics():
UpdateRender():
As I said before, it all runs fine if compiled from MSVC++ 2008.
UpdatePhysics():
Code: Select all
void UpdatePhysics(u32 TDeltaTime, EPhysics* Physics)
{
Physics->World->stepSimulation(TDeltaTime * 0.001f, 2);
for(list<btRigidBody *>::Iterator Iterator = Physics->Objects.begin(); Iterator != Physics->Objects.end(); ++Iterator)
{
UpdateRender(*Iterator, Physics);
}
};
Code: Select all
void UpdateRender(btRigidBody *TObject, EPhysics* Physics)
{
ISceneNode *Node = static_cast<ISceneNode *>(TObject->getUserPointer());
// Set position
btVector3 Point = TObject->getCenterOfMassPosition();
Node->setPosition(vector3df((f32)Point[0], (f32)Point[1], (f32)Point[2]));
// Set rotation
btVector3 EulerRotation;
QuaternionToEuler(TObject->getOrientation(), EulerRotation);
Node->setRotation(vector3df(EulerRotation[0], EulerRotation[1], EulerRotation[2]));
};
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
Well, that code looks fine indeed (besides manually updating the irrlicht nodes).
Make sure you don't link against MSVC compiled libraries of Bullet and Irrlicht when compiling your app with MinGW.
And don't have MSVC DLLs in your system path or in the same folder as your MinGW executable.
If this still doesn't help, it's time for posting the whole code i guess.
Btw, using constant references rather than copy by value will increase performance. e.g.
Make sure you don't link against MSVC compiled libraries of Bullet and Irrlicht when compiling your app with MinGW.
And don't have MSVC DLLs in your system path or in the same folder as your MinGW executable.
If this still doesn't help, it's time for posting the whole code i guess.
Btw, using constant references rather than copy by value will increase performance. e.g.
Code: Select all
const btVector3& Point = TObject->getCenterOfMassPosition();
"Whoops..."
I'm not, I compiled new libs specifically for the CB version.
I'm up for posting the whole code. Should I post a link to a zip file? It would take up alot of screen space on here.
Like I said, if you want to try compiling it, I can give you the project files. Its open source, so I don't care if you copy anything. Just don't take any major ideas
And, thanks, I didn't know that I'll patch my code sometime soon.
I'm up for posting the whole code. Should I post a link to a zip file? It would take up alot of screen space on here.
Like I said, if you want to try compiling it, I can give you the project files. Its open source, so I don't care if you copy anything. Just don't take any major ideas
And, thanks, I didn't know that I'll patch my code sometime soon.
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
It would be best to post a minimal compilable snippet which reproduces the problem here, usingBuck1000 wrote:Should I post a link to a zip file? It would take up alot of screen space on here.
Code: Select all
tags. Just leave unimportant code out.
"Whoops..."
Okay, I posted at first my quick and dirty attempt at shortening my program, but quickly realized that it was still too big, and you asked for the simplest compilable example =] So, I further deleted things, and compressed it all into one file. Except now I get other errors, that I've never seen before xD It compiles and links, but here is the call stack when it is run. I debugged it, and execution stops before it ever reaches main(). I tried to single step into the first line, and it crashed right away.
Call Stack
Notice how the #1 call is at line 404? Main.cpp only has 125 lines. Thats including whitespace.
And, the code -
Main.cpp
Call Stack
Code: Select all
#0 00000000 __static_initialization_and_destruction_0(__initialize_p=1, __priority=65535) (F:/Libraries/irrlicht-1.6/include/IQ3Shader.h:21)
#1 00401E92 global constructors keyed to main() (C:/Documents and Settings/Cris/Desktop/Aftermath_V3/main.cpp:404)
#2 0047A452 __do_global_ctors() (F:/Libraries/irrlicht-1.6/include/IQ3Shader.h:21)
#3 00401095 __mingw_CRTStartup() (??:??)
#4 00401128 WinMainCRTStartup() (??:??)
And, the code -
Main.cpp
Code: Select all
#include <irrlicht.h>
#include <iostream>
#include <btBulletCollisionCommon.h>
#include <btBulletDynamicsCommon.h>
using namespace std;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == EET_KEY_INPUT_EVENT)
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
virtual bool IsKeyDown(EKEY_CODE keyCode) const
{
return KeyIsDown[keyCode];
}
MyEventReceiver()
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown[i] = false;
}
private:
bool KeyIsDown[KEY_KEY_CODES_COUNT];
};
struct EPhysics
{
btDiscreteDynamicsWorld* World;
btVector3 Gravity;
list<btRigidBody *> Objects;
};
void UpdatePhysics(u32 TDeltaTime, EPhysics* Physics);
void UpdateRender(btRigidBody *TObject, EPhysics* Physics);
int main()
{
//Irrlicht Setup
EPhysics Physics;
MyEventReceiver receiver;
SIrrlichtCreationParameters params;
params.AntiAlias=false;
params.Stencilbuffer=false;
params.Vsync=true;
params.WindowSize=dimension2d<s32>(1024,768);
params.Bits=32;
params.Fullscreen=false;
params.EventReceiver=&receiver;
params.DriverType=EDT_OPENGL;
IrrlichtDevice* device=createDeviceEx(params);
if(device==0)
return 1;
device->getCursorControl()->setVisible(false);
IVideoDriver* driver=device->getVideoDriver();
ISceneManager* smgr=device->getSceneManager();
IGUIEnvironment* gui=device->getGUIEnvironment();
ITimer* timer= device->getTimer();
//Bullet Physics
btDefaultCollisionConfiguration* CollisionConfiguration = new btDefaultCollisionConfiguration();
btBroadphaseInterface* BroadPhase = new btAxisSweep3(btVector3(-100000, -100000, -100000), btVector3(100000, 100000, 100000));
btCollisionDispatcher* Dispatcher = new btCollisionDispatcher(CollisionConfiguration);
btSequentialImpulseConstraintSolver* Solver = new btSequentialImpulseConstraintSolver();
Physics.World = new btDiscreteDynamicsWorld(Dispatcher, BroadPhase, Solver, CollisionConfiguration);
Physics.World->setGravity(btVector3(0,-9,0));
Physics.Objects.clear();
//Main Loop
u32 TimeStamp = timer->getTime(), DeltaTime = 0;
while(device->run() && driver)
{
DeltaTime = timer->getTime() - TimeStamp;
TimeStamp = timer->getTime();
UpdatePhysics(DeltaTime, &Physics);
//Simple Exit Call
if(receiver.IsKeyDown(KEY_ESCAPE))
break;
//Drawing loop
driver->beginScene(true,true,0);
smgr->drawAll();
gui->drawAll();
driver->endScene();
};
device->drop();
return 0;
}
void UpdatePhysics(u32 TDeltaTime, EPhysics* Physics)
{
Physics->World->stepSimulation(TDeltaTime * 0.001f, 2);
for(list<btRigidBody *>::Iterator Iterator = Physics->Objects.begin(); Iterator != Physics->Objects.end(); ++Iterator)
{
UpdateRender(*Iterator, Physics);
}
};
void UpdateRender(btRigidBody* TObject, EPhysics* Physics)
{
ISceneNode* Node = static_cast<ISceneNode *>(TObject->getUserPointer());
// Set position
const btVector3& Point = TObject->getCenterOfMassPosition();
Node->setPosition(vector3df((f32)Point[0], (f32)Point[1], (f32)Point[2]));
};
That was it, thank you =] I would have absolutely never thought of that.
Well, same code, crashes as before with the call to removeCollisionObject() in the call stack.
For reference, here is all the info in one spot -
Main.cpp
Call Stack
So, theres your minimal snippet =] Can you try compiling it, and see if it crashes the same on your pc?
Well, same code, crashes as before with the call to removeCollisionObject() in the call stack.
For reference, here is all the info in one spot -
Main.cpp
Code: Select all
#include <irrlicht.h>
#include <iostream>
#include <btBulletCollisionCommon.h>
#include <btBulletDynamicsCommon.h>
using namespace std;
using namespace irr;
using namespace core;
using namespace scene;
using namespace video;
using namespace io;
using namespace gui;
class MyEventReceiver : public IEventReceiver
{
public:
virtual bool OnEvent(const SEvent& event)
{
if (event.EventType == EET_KEY_INPUT_EVENT)
KeyIsDown[event.KeyInput.Key] = event.KeyInput.PressedDown;
return false;
}
virtual bool IsKeyDown(EKEY_CODE keyCode) const
{
return KeyIsDown[keyCode];
}
MyEventReceiver()
{
for (u32 i=0; i<KEY_KEY_CODES_COUNT; ++i)
KeyIsDown[i] = false;
}
private:
bool KeyIsDown[KEY_KEY_CODES_COUNT];
};
struct EPhysics
{
btDiscreteDynamicsWorld* World;
btVector3 Gravity;
list<btRigidBody *> Objects;
};
void UpdatePhysics(u32 TDeltaTime, EPhysics* Physics);
void UpdateRender(btRigidBody *TObject, EPhysics* Physics);
int main()
{
//Irrlicht Setup
EPhysics Physics;
MyEventReceiver receiver;
SIrrlichtCreationParameters params;
params.AntiAlias=false;
params.Stencilbuffer=false;
params.Vsync=true;
params.WindowSize=dimension2d<s32>(1024,768);
params.Bits=32;
params.Fullscreen=false;
params.EventReceiver=&receiver;
params.DriverType=EDT_OPENGL;
IrrlichtDevice* device=createDeviceEx(params);
if(device==0)
return 1;
device->getCursorControl()->setVisible(false);
IVideoDriver* driver=device->getVideoDriver();
ISceneManager* smgr=device->getSceneManager();
IGUIEnvironment* gui=device->getGUIEnvironment();
ITimer* timer= device->getTimer();
//Bullet Physics
btDefaultCollisionConfiguration* CollisionConfiguration = new btDefaultCollisionConfiguration();
btBroadphaseInterface* BroadPhase = new btAxisSweep3(btVector3(-100000, -100000, -100000), btVector3(100000, 100000, 100000));
btCollisionDispatcher* Dispatcher = new btCollisionDispatcher(CollisionConfiguration);
btSequentialImpulseConstraintSolver* Solver = new btSequentialImpulseConstraintSolver();
Physics.World = new btDiscreteDynamicsWorld(Dispatcher, BroadPhase, Solver, CollisionConfiguration);
Physics.World->setGravity(btVector3(0,-9,0));
Physics.Objects.clear();
//Main Loop
u32 TimeStamp = timer->getTime(), DeltaTime = 0;
while(device->run() && driver)
{
DeltaTime = timer->getTime() - TimeStamp;
TimeStamp = timer->getTime();
UpdatePhysics(DeltaTime, &Physics);
//Simple Exit Call
if(receiver.IsKeyDown(KEY_ESCAPE))
break;
//Drawing loop
driver->beginScene(true,true,0);
smgr->drawAll();
gui->drawAll();
driver->endScene();
};
device->drop();
return 0;
}
void UpdatePhysics(u32 TDeltaTime, EPhysics* Physics)
{
Physics->World->stepSimulation(TDeltaTime * 0.001f, 2);
for(list<btRigidBody *>::Iterator Iterator = Physics->Objects.begin(); Iterator != Physics->Objects.end(); ++Iterator)
{
UpdateRender(*Iterator, Physics);
}
};
void UpdateRender(btRigidBody* TObject, EPhysics* Physics)
{
ISceneNode* Node = static_cast<ISceneNode *>(TObject->getUserPointer());
// Set position
const btVector3& Point = TObject->getCenterOfMassPosition();
Node->setPosition(vector3df((f32)Point[0], (f32)Point[1], (f32)Point[2]));
};
Code: Select all
#0 004031B9 btDiscreteDynamicsWorld::removeCollisionObject(btCollisionObject*) () (F:/Libraries/irrlicht-1.6/include/IQ3Shader.h:21)
#1 00401D08 UpdatePhysics(TDeltaTime=424, Physics=0x22ff10) (C:/Documents and Settings/Cris/Desktop/Aftermath_V3/main.cpp:109)
#2 00401B03 main() (C:/Documents and Settings/Cris/Desktop/Aftermath_V3/main.cpp:89)
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
-
- Posts: 1186
- Joined: Fri Dec 29, 2006 12:04 am
No, that's not the reason. You just 'lose' memory every time you run the app.Buck1000 wrote:Thats probably why it crashes in windows.
Yes, sure.Buck1000 wrote:Do you know where they are?
You have to
Code: Select all
delete Physics.World;
delete Solver;
delete Dispatcher;
delete BroadPhase;
delete CollisionConfiguration;
"Whoops..."