Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Debug Error , QT 6_2_1 MSVC20119 when i try to use OGR 3D in Qt
Forum Updated to NodeBB v4.3 + New Features

Debug Error , QT 6_2_1 MSVC20119 when i try to use OGR 3D in Qt

Scheduled Pinned Locked Moved Unsolved General and Desktop
13 Posts 4 Posters 739 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • A Offline
    A Offline
    Alex42
    wrote on last edited by
    #1

    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 .
    Capture.PNG

    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
    Capture.PNG

    Note that I tried to compile some projects with VS2019 and it runs

    feedback, advice you are welcome
    thak you in dvance

    1 Reply Last reply
    0
    • Christian EhrlicherC Online
      Christian EhrlicherC Online
      Christian Ehrlicher
      Lifetime Qt Champion
      wrote on last edited by
      #2

      As always when a program is crashing - run in debugger, see where it crashes.

      Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
      Visit the Qt Academy at https://academy.qt.io/catalog

      1 Reply Last reply
      0
      • A Offline
        A Offline
        Alex42
        wrote on last edited by
        #3

        hi , and thank you for your answer,
        i run in debugger , and crashed here Capture2.PNG
        when i create an instance of this class

         QOgreBasicTest *testOgre = new QOgreBasicTest();
        
        JonBJ 1 Reply Last reply
        0
        • A Offline
          A Offline
          Alex42
          wrote on last edited by
          #4

          i have exactly the same problem when i try to use a console aplic

          1 Reply Last reply
          0
          • A Offline
            A Offline
            Alex42
            wrote on last edited by
            #5

            I have exactly the same problem when I try to use a console application, with another code approach ,
            here's my .main file

            class 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;
            }
            
            1 Reply Last reply
            0
            • A Alex42

              hi , and thank you for your answer,
              i run in debugger , and crashed here Capture2.PNG
              when i create an instance of this class

               QOgreBasicTest *testOgre = new QOgreBasicTest();
              
              JonBJ Online
              JonBJ Online
              JonB
              wrote on last edited by JonB
              #6

              @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?

              1 Reply Last reply
              0
              • A Offline
                A Offline
                Alex42
                wrote on last edited by
                #7

                @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
                Capture3.PNG

                1 Reply Last reply
                0
                • A Offline
                  A Offline
                  Alex42
                  wrote on last edited by
                  #8

                  @JonB said in Debug Error , QT 6_2_1 MSVC20119 when i try to use OGR 3D in Qt:

                  If it crashes while executing that line then let it do so and show the stack trace after the crash has happened?
                  for more details
                  Capture4.PNG

                  1 Reply Last reply
                  0
                  • A Offline
                    A Offline
                    Alex42
                    wrote on last edited by
                    #9

                    (other program )when i run in only main cpp , i have the same problem
                    Capture5.PNG

                     Application MonApplication ;
                             MonApplication.Start ();
                             MonApplication.Run() ;
                    
                    jsulmJ 1 Reply Last reply
                    0
                    • A Alex42

                      (other program )when i run in only main cpp , i have the same problem
                      Capture5.PNG

                       Application MonApplication ;
                               MonApplication.Start ();
                               MonApplication.Run() ;
                      
                      jsulmJ Offline
                      jsulmJ Offline
                      jsulm
                      Lifetime Qt Champion
                      wrote on last edited by
                      #10

                      @Alex42 It crashes inside Ogre::Root(), so step into it and see what happens.

                      https://forum.qt.io/topic/113070/qt-code-of-conduct

                      1 Reply Last reply
                      1
                      • A Offline
                        A Offline
                        Alex42
                        wrote on last edited by
                        #11

                        @jsulm said in Debug Error , QT 6_2_1 MSVC20119 when i try to use OGR 3D in Qt:

                        step into it

                        i don' know why i can't setup into it , i obtain this error every time i try to setup into it
                        Capture5.PNG

                        1 Reply Last reply
                        0
                        • A Offline
                          A Offline
                          Alex42
                          wrote on last edited by
                          #12

                          i see many project use ogr in Qt , but under cMake not under qmake , for this i think the probleme is qmake

                          1 Reply Last reply
                          0
                          • Christian EhrlicherC Online
                            Christian EhrlicherC Online
                            Christian Ehrlicher
                            Lifetime Qt Champion
                            wrote on last edited by
                            #13

                            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

                            Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
                            Visit the Qt Academy at https://academy.qt.io/catalog

                            1 Reply Last reply
                            2

                            • Login

                            • Login or register to search.
                            • First post
                              Last post
                            0
                            • Categories
                            • Recent
                            • Tags
                            • Popular
                            • Users
                            • Groups
                            • Search
                            • Get Qt Extensions
                            • Unsolved