Qt + Ogre3D. I cannot build a very simple example

408 Views Asked by At

I use:

  • Qt 5.15.2 MinGW 32-bit Dynamic for Debug build
  • Ogre 13.1.1 MinGW Static build

There is a class called ApplicationContextQt that can help to use Qt with Ogre3D but I have errors:

47a689b0-2071-4a12-a430-677f9bfe8d03-image.png

This example is very simple:

main.cpp

#include "Ogre.h"
#include "OgreApplicationContextQt.h"
#include <QGuiApplication>

class MyTestApp : public OgreBites::ApplicationContextQt, public OgreBites::InputListener
{
public:
    MyTestApp();
    void setup();
    bool keyPressed(const OgreBites::KeyboardEvent& evt);
};

MyTestApp::MyTestApp() : OgreBites::ApplicationContextQt("OgreTutorialApp")
{
}

bool MyTestApp::keyPressed(const OgreBites::KeyboardEvent& evt)
{
    if (evt.keysym.sym == OgreBites::SDLK_ESCAPE)
    {
        getRoot()->queueEndRendering();
    }
    return true;
}

void MyTestApp::setup(void)
{
    // do not forget to call the base first
    OgreBites::ApplicationContextQt::setup();

}

int main(int argc, char *argv[])
{
    QGuiApplication qapp(argc, argv);
    MyTestApp app;
    app.initApp();
    app.getRoot()->startRendering();
    app.closeApp();
    return qapp.exec();
}
INCLUDEPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE"
INCLUDEPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE\Bites"
INCLUDEPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE\RTShaderSystem"

LIBS += -L"E:\ProgramFiles\ogre-13.1.1\lib"
LIBS += -L"E:\ProgramFiles\ogre-13.1.1\lib\OGRE"

LIBS += -lOgreBitesQtStatic
LIBS += -lOgreBitesStatic -lRenderSystem_GL3PlusStatic -lOgreGLSupportStatic -lOgreMeshLodGeneratorStatic -lOgreOverlayStatic -lOgrePagingStatic -lOgrePropertyStatic -lOgreRTShaderSystemStatic -lOgreVolumeStatic -lPlugin_BSPSceneManagerStatic -lPlugin_DotSceneStatic -lPlugin_OctreeSceneManagerStatic -lPlugin_OctreeZoneStatic -lPlugin_ParticleFXStatic -lPlugin_PCZSceneManagerStatic -lRenderSystem_GLES2Static -lRenderSystem_GLStatic -lOgreMainStatic -lOgreTerrainStatic -lCodec_STBIStatic -lzlibstatic
LIBS += -lSDL2main -lSDL2.dll -lfreetype -lpugixml
LIBS += -lopengl32 -lgdi32
1

There are 1 best solutions below

0
Fenilalanin On

You can try this one ?

INCLUDEPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE"
INCLUDEPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE\Bites"
INCLUDEPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE\RTShaderSystem"

DEPENDPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE"
DEPENDPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE\Bites"
DEPENDPATH += "E:\ProgramFiles\ogre-13.1.1\include\OGRE\RTShaderSystem"

LIBS += -L"E:/ProgramFiles/ogre-13.1.1/lib/OgreBitesQtStatic" -lOgreBitesQtStatic
LIBS += -L"E:/ProgramFiles/ogre-13.1.1/lib/OGRE" -lOgreBitesStatic
// OR ...
LIBS += "E:/ProgramFiles/ogre-13.1.1/lib/OgreBitesQtStatic/OgreBitesQtStatic.a"
LIBS += "E:/ProgramFiles/ogre-13.1.1/lib/OGRE/OgreBitesStatic.a"
// It just depends on the actual names of your libraries

// Same for the others unless their file location is decleared under system path. 
// If so, you can add that libraries like how you did with opengl

And it is nice to add PRE_TARGETDEPS macros too if you make changes on those libraries so often:

PRE_TARGETDEPS += "E:/ProgramFiles/ogre-13.1.1/lib/OgreBitesQtStatic.a"

You can replace "/"s with "" too.

And the problem with your pro file was: You added library paths as libraries. And then tried to add that libraries from system environment.