Debug Error , QT 6_2_1 MSVC20119 when i try to use OGR 3D in Qt
-
Hello everybody
I was able to configure, compile and install ogre3D, and when i try to test a simple project i have the MSVC compiler error .
I made a simple class , where I more or less copy a basic tutorial code:
here's the .h header#ifndef QOGREBASICTEST_H #define QOGREBASICTEST_H #include <QDebug> #include "Ogre.h" #include "OgreApplicationContextQt.h" #include "OgreInput.h" #include "OgreRTShaderSystem.h" #include <iostream> using namespace Ogre; using namespace OgreBites; class QOgreBasicTest : public ApplicationContextQt , public InputListener { public: QOgreBasicTest(); virtual ~QOgreBasicTest() {} void setup(); bool keyPressed(const KeyboardEvent& evt); }; #endif // QOGREBASICTEST_H
and the .cpp
#include "QOgreBasicTest.h" QOgreBasicTest::QOgreBasicTest() : ApplicationContextQt("QtOgreTest1") { qInfo()<<"1"; } void QOgreBasicTest::setup() { // do not forget to call the base first qInfo()<<"2"; ApplicationContextQt::setup(); qInfo()<<"3"; addInputListener(this); // get a pointer to the already created root Root* root = getRoot(); SceneManager* scnMgr = root->createSceneManager(); // register our scene with the RTSS RTShader::ShaderGenerator* shadergen = RTShader::ShaderGenerator::getSingletonPtr(); shadergen->addSceneManager(scnMgr); // -- tutorial section start -- //! [turnlights] scnMgr->setAmbientLight(ColourValue(0.5, 0.5, 0.5)); //! [turnlights] //! [newlight] Light* light = scnMgr->createLight("MainLight"); SceneNode* lightNode = scnMgr->getRootSceneNode()->createChildSceneNode(); lightNode->attachObject(light); //! [newlight] //! [lightpos] lightNode->setPosition(20, 80, 50); //! [lightpos] //! [camera] SceneNode* camNode = scnMgr->getRootSceneNode()->createChildSceneNode(); // create the camera Camera* cam = scnMgr->createCamera("myCam"); cam->setNearClipDistance(5); // specific to this sample cam->setAutoAspectRatio(true); camNode->attachObject(cam); camNode->setPosition(0, 0, 140); // and tell it to render into the main window getRenderWindow()->addViewport(cam); //! [camera] //! [entity1] Entity* ogreEntity = scnMgr->createEntity("ogrehead.mesh"); //! [entity1] //! [entity1node] SceneNode* ogreNode = scnMgr->getRootSceneNode()->createChildSceneNode(); //! [entity1node] //! [entity1nodeattach] ogreNode->attachObject(ogreEntity); //! [entity1nodeattach] //! [cameramove] camNode->setPosition(0, 47, 222); //! [cameramove] //! [entity2] Entity* ogreEntity2 = scnMgr->createEntity("ogrehead.mesh"); SceneNode* ogreNode2 = scnMgr->getRootSceneNode()->createChildSceneNode(Vector3(84, 48, 0)); ogreNode2->attachObject(ogreEntity2); //! [entity2] //! [entity3] Entity* ogreEntity3 = scnMgr->createEntity("ogrehead.mesh"); SceneNode* ogreNode3 = scnMgr->getRootSceneNode()->createChildSceneNode(); ogreNode3->setPosition(0, 104, 0); ogreNode3->setScale(2, 1.2, 1); ogreNode3->attachObject(ogreEntity3); //! [entity3] //! [entity4] Entity* ogreEntity4 = scnMgr->createEntity("ogrehead.mesh"); SceneNode* ogreNode4 = scnMgr->getRootSceneNode()->createChildSceneNode(); ogreNode4->setPosition(-84, 48, 0); ogreNode4->roll(Degree(-90)); ogreNode4->attachObject(ogreEntity4); //! [entity4] // -- tutorial section end -- } bool QOgreBasicTest::keyPressed(const KeyboardEvent &evt) { if (evt.keysym.sym == SDLK_ESCAPE) { getRoot()->queueEndRendering(); } return true; }
Well, if I stop here, it compiles with no error.
So in my mainwindow, I just put a push button to create an instance of this class
here's the code of the button
void MainWindow::on_pushButton_clicked() { //QOgreBasicTest *testOgre = new QOgreBasicTest(); //testOgre->setup(); }
If I let those 2 lines commented, the code compile, the app start
if I uncomment those lines (even the first one)... the code compile and the app crash immediatly with Debug Error , QT 6_2_1 MSVC20119
Note that I tried to compile some projects with VS2019 and it runs
feedback, advice you are welcome
thak you in dvance -
As always when a program is crashing - run in debugger, see where it crashes.
-
I have exactly the same problem when I try to use a console application, with another code approach ,
here's my .main fileclass Application { public : Application(); ~Application(); void Start(); void Run(); void Exit(); public : Ogre::Root* pRoot; Ogre::SceneManager* pSceneManager; Ogre::RenderWindow* pRenderWindow; Ogre::Viewport* pViewport; Ogre::Camera* pCamera; }; Application::Application() { pRoot = 0; pSceneManager = 0; pRenderWindow = 0; pViewport = 0; pCamera = 0; } Application::~Application() { Exit(); } void Application::Run() { pRoot->startRendering(); } void Application::Start() { qInfo() << "tested"; pRoot = new Ogre::Root(); qInfo() << "tested"; pRenderWindow = pRoot->initialise(true,"Ma premiere application Ogre"); pSceneManager = pRoot->createSceneManager("MonGestionnaireDeScene"); pCamera = pSceneManager->createCamera("MaCamera"); pViewport = pRenderWindow->addViewport(pCamera); } void Application::Exit() { if (pRoot!=0) delete pRoot; } #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 #define WIN32_LEAN_AND_MEAN #include "windows.h" INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR strCmdLine, INT ) #else int main(int argc, char **argv) #endif { try { Application MonApplication ; MonApplication.Start (); MonApplication.Run() ; qInfo() << "tested"; MonApplication.Exit(); } catch( Ogre::Exception &e ) { #if OGRE_PLATFORM == OGRE_PLATFORM_WIN32 //MessageBox( NULL, e.what(), "An exception has occurred!", MB_OK | MB_ICONERROR | MB_TASKMODAL); qInfo() << "fucking"; #else fprintf(stderr, "An exception has occurred: %s\n", e.what()); #endif } return 0; }
-
hi , and thank you for your answer,
i run in debugger , and crashed here
when i create an instance of this classQOgreBasicTest *testOgre = new QOgreBasicTest();
@Alex42 said in Debug Error , QT 6_2_1 MSVC20119 when i try to use OGR 3D in Qt:
i run in debugger , and crashed here
What I see in your screenshot is the debugger stopped at a breakpoint on the start of
on_pushButton_clicked()
, not "crashed" in the screenshot like you claim?when i create an instance of this class
QOgreBasicTest *testOgre = new QOgreBasicTest();
If it crashes while executing that line then let it do so and show the stack trace after the crash has happened?
-
@JonB said in Debug Error , QT 6_2_1 MSVC20119 when i try to use OGR 3D in Qt:
What I see in your screenshot is the debugger stopped at a breakpoint on the start of on_pushButton_clicked(), not "crashed" in the screenshot like you claim?
hi @JonB thank you for your answer
here the screenshot when i try to unfold the debug withe another exception
-
(other program )when i run in only main cpp , i have the same problem
Application MonApplication ; MonApplication.Start (); MonApplication.Run() ;
-
You're mixing debug and release dlls which is not allowed under windows. Compile ogre in debug mode and use these libraries. You must not mix VCRUNTIMExxx.dll and VCRUNTIMExxxD.dll