Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Game Development
  4. Qt + Ogre3D. I cannot build a very simple example
Forum Updated to NodeBB v4.3 + New Features

Qt + Ogre3D. I cannot build a very simple example

Scheduled Pinned Locked Moved Unsolved Game Development
20 Posts 6 Posters 3.7k Views 3 Watching
  • 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.
  • 8Observer88 Offline
    8Observer88 Offline
    8Observer8
    wrote on last edited by
    #6

    I think that Ogre cannot work with qmake and I should use CMake instead of qmake:

    3cca210a-7171-49f8-83f2-ed4bbc8b888c-image.png

    1 Reply Last reply
    0
    • 8Observer88 Offline
      8Observer88 Offline
      8Observer8
      wrote on last edited by
      #7

      I made everything like in this instruction: https://ogrecave.github.io/ogre/api/latest/setup.html#cmake

      I added OGRE_DIR to Environment Variables (where OGREConfig.cmake is located):

      OGRE_DIR.png

      I created a new Qt Widget project with CMake instead of qmake:

      9a3ec88f-a814-40c3-b256-de7d37ff762b-image.png

      I added this line from instruction above CMakeLists.txt:

      if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
          qt_add_executable(BootstrapCMakeQt5Cpp
              ${PROJECT_SOURCES}
          )
      else()
          if(ANDROID)
              add_library(BootstrapCMakeQt5Cpp SHARED
                  ${PROJECT_SOURCES}
              )
          else()
              add_executable(BootstrapCMakeQt5Cpp
                  ${PROJECT_SOURCES}
              )
          endif()
      endif()
      
      find_package(OGRE REQUIRED COMPONENTS Bites RTShaderSystem CONFIG)
      target_link_libraries(BootstrapCMakeQt5Cpp PRIVATE Qt${QT_VERSION_MAJOR}::Widgets OgreBitesQt OgreRTShaderSystem)
      

      But that tutorial works for shared libs only and does not work for static. So I have these errors:

      CMake Error at CMakeLists.txt:44 (add_executable):
        Target "BootstrapCMakeQt5Cpp" links to target "ZLIB::ZLIB" but the target
        was not found.  Perhaps a find_package() call is missing for an IMPORTED
        target, or an ALIAS target is missing?
      
      
      CMake Error at CMakeLists.txt:44 (add_executable):
        Target "BootstrapCMakeQt5Cpp" links to target "SDL2::SDL2" but the target
        was not found.  Perhaps a find_package() call is missing for an IMPORTED
        target, or an ALIAS target is missing?
      
      1 Reply Last reply
      0
      • 8Observer88 Offline
        8Observer88 Offline
        8Observer8
        wrote on last edited by
        #8

        I see how to add OgreBitesQt here:

        target_link_libraries(BootstrapCMakeQt5Cpp PRIVATE Qt${QT_VERSION_MAJOR}::Widgets OgreBitesQt OgreRTShaderSystem)
        

        But how to add BitesQt here:

        find_package(OGRE REQUIRED COMPONENTS Bites RTShaderSystem CONFIG)
        
        1 Reply Last reply
        0
        • SGaistS Offline
          SGaistS Offline
          SGaist
          Lifetime Qt Champion
          wrote on last edited by
          #9

          Then you should start by making a minimal Ogre only application build and then add Qt to the mix.

          And if it still fails, you should check with the Ogre folks.

          Note that you would likely have less trouble using a classic dynamic build of Ogre.

          Interested in AI ? www.idiap.ch
          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

          1 Reply Last reply
          0
          • 8Observer88 Offline
            8Observer88 Offline
            8Observer8
            wrote on last edited by 8Observer8
            #10

            My goal now is to check can Ogre works with Qt for static or not. If it cannot I will continue usage of OpenGL, and I will not spend my time for Ogre. And I want to check can I integrate Ogre inside of Qt Widget for static build.

            This message Target "BootstrapCMakeQt5Cpp" links to target "ZLIB::ZLIB" but the target was not found. says that I should to add ZLIB::ZLIB here:

            target_link_libraries(BootstrapCMakeQt5Cpp PRIVATE Qt${QT_VERSION_MAJOR}::Widgets OgreBitesQt OgreRTShaderSystem ZLIB::ZLIB)
            

            But before it I should to add this line: find_package(ZLIB). Ogre already has zlib. But it does not work again:

            find_package(ZLIB)
            
            find_package(OGRE REQUIRED COMPONENTS Bites RTShaderSystem CONFIG)
            target_link_libraries(BootstrapCMakeQt5Cpp PRIVATE Qt${QT_VERSION_MAJOR}::Widgets OgreBitesQt OgreRTShaderSystem ZLIB::ZLIB)
            

            It says again:

            CMake Error at CMakeLists.txt:44 (add_executable):
              Target "BootstrapCMakeQt5Cpp" links to target "ZLIB::ZLIB" but the target
              was not found.  Perhaps a find_package() call is missing for an IMPORTED
              target, or an ALIAS target is missing?
            
            1 Reply Last reply
            0
            • 8Observer88 Offline
              8Observer88 Offline
              8Observer8
              wrote on last edited by 8Observer8
              #11

              I solved the problems with SDL2 and ZLIB that was in the message above. Now configuration is passing. But when I build it i see the same errors like in the first post with qmake:

              12765ae5-6766-401f-9f08-3610d2f78e9f-image.png

              CMakeLists.txt

              cmake_minimum_required(VERSION 3.5)
              
              project(BootstrapCMakeQt5Cpp LANGUAGES CXX)
              
              set(CMAKE_INCLUDE_CURRENT_DIR ON)
              
              set(CMAKE_AUTOUIC ON)
              set(CMAKE_AUTOMOC ON)
              set(CMAKE_AUTORCC ON)
              
              set(CMAKE_CXX_STANDARD 11)
              set(CMAKE_CXX_STANDARD_REQUIRED ON)
              link_directories("E:/ProgramFiles/ogre-13.1.1/lib")
              
              find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
              find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
              
              set(PROJECT_SOURCES
                      main.cpp
              )
              
              if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
                  qt_add_executable(BootstrapCMakeQt5Cpp
                      ${PROJECT_SOURCES}
                  )
              else()
                  if(ANDROID)
                      add_library(BootstrapCMakeQt5Cpp SHARED
                          ${PROJECT_SOURCES}
                      )
                  else()
                      add_executable(BootstrapCMakeQt5Cpp
                          ${PROJECT_SOURCES}
                      )
                  endif()
              endif()
              
              #find_package(ZLIB REQUIRED)
              add_library(ZLIB::ZLIB INTERFACE IMPORTED)
              add_library(SDL2::SDL2 INTERFACE IMPORTED)
              find_package(OGRE REQUIRED COMPONENTS Bites RTShaderSystem CONFIG)
              
              target_link_libraries(BootstrapCMakeQt5Cpp PRIVATE Qt${QT_VERSION_MAJOR}::Widgets OgreBitesQt OgreRTShaderSystem)
              

              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();
              }
              
              1 Reply Last reply
              0
              • 8Observer88 Offline
                8Observer88 Offline
                8Observer8
                wrote on last edited by 8Observer8
                #12

                I added OgreApplicationContextQt.cpp directly in my code:

                OgreApplicationContextQt.png

                I added Q_OBJECT to MyTestApp.h. I have a little different errors:

                Q_OBJECT.png

                These are all my files:

                MyTestApp.h

                #ifndef MYTESTAPP_H
                #define MYTESTAPP_H
                
                #include "Ogre.h"
                #include "OgreApplicationContextQt.h"
                #include <QtCore/QObject>
                
                class MyTestApp : public OgreBites::ApplicationContextQt, public OgreBites::InputListener
                {
                    Q_OBJECT
                public:
                    MyTestApp();
                    virtual ~MyTestApp() { }
                    void setup();
                    bool keyPressed(const OgreBites::KeyboardEvent& evt);
                };
                
                #endif // MYTESTAPP_H
                

                MyTestApp.cpp

                #include "MyTestApp.h"
                
                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();
                
                }
                

                main.cpp

                #include <QGuiApplication>
                #include "MyTestApp.h"
                
                int main(int argc, char *argv[])
                {
                    QGuiApplication qapp(argc, argv);
                    MyTestApp app;
                    app.initApp();
                    app.getRoot()->startRendering();
                    app.closeApp();
                    return qapp.exec();
                }
                

                .pro

                QT       += core gui
                
                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
                # -lOgreMeshLodGeneratorStatic
                # -lOgrePagingStatic
                # -lOgrePropertyStatic
                LIBS += -lOgreBitesStatic -lRenderSystem_GL3PlusStatic -lOgreGLSupportStatic -lOgreOverlayStatic   -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
                
                greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
                
                CONFIG += c++11
                
                # You can make your code fail to compile if it uses deprecated APIs.
                # In order to do so, uncomment the following line.
                #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
                
                SOURCES += \
                    MyTestApp.cpp \
                    OgreApplicationContextQt.cpp \
                    main.cpp
                
                HEADERS += \
                    MyTestApp.h
                
                # Default rules for deployment.
                qnx: target.path = /tmp/$${TARGET}/bin
                else: unix:!android: target.path = /opt/$${TARGET}/bin
                !isEmpty(target.path): INSTALLS += target
                
                1 Reply Last reply
                0
                • 8Observer88 Offline
                  8Observer88 Offline
                  8Observer8
                  wrote on last edited by 8Observer8
                  #13

                  I try to compile the same very simple and basic example that I tried before with cmake. Сonfiguration with cmake was made without errors:

                  -- Found OGRE
                  --   static     : ON
                  --   components : Bites;MeshLodGenerator;Overlay;Paging;Property;RTShaderSystem;Terrain;Volume
                  --   plugins    : Plugin_BSPSceneManager;Plugin_OctreeSceneManager;Plugin_PCZSceneManager;Plugin_ParticleFX;RenderSystem_GL;RenderSystem_GLES2;RenderSystem_GL3Plus;Codec_STBI
                  --   media      : E:/ProgramFiles/ogre-13.1.1/Media
                  -- Configuring done
                  -- Generating done
                  -- Build files have been written to: E:/_Projects/Ogre3D/build-BootstrapCMakeQt5Cpp-Desktop_Qt_5_15_2_MinGW_32_bit-Debug
                  Elapsed time: 00:01.
                  

                  But when I build the project I see a few new errors undefined reference to 'compressBound' and undefined reference to 'compress' in OgreSTBICodec.cpp:

                  1ec8dd51-16c5-4259-840f-d3bb5eda944b-image.png

                  I added OgreApplicationContextQt.cpp to the project:

                  1a190f53-7aa0-4eaf-a76f-52cc662e9368-image.png

                  CMakeLists.txt

                  cmake_minimum_required(VERSION 3.5)
                  
                  project(BootstrapCMakeQt5Cpp LANGUAGES CXX)
                  
                  set(CMAKE_INCLUDE_CURRENT_DIR ON)
                  
                  set(CMAKE_AUTOUIC ON)
                  set(CMAKE_AUTOMOC ON)
                  set(CMAKE_AUTORCC ON)
                  
                  set(CMAKE_CXX_STANDARD 11)
                  set(CMAKE_CXX_STANDARD_REQUIRED ON)
                  link_directories("E:/ProgramFiles/ogre-13.1.1/lib")
                  
                  find_package(QT NAMES Qt6 Qt5 COMPONENTS Widgets REQUIRED)
                  find_package(Qt${QT_VERSION_MAJOR} COMPONENTS Widgets REQUIRED)
                  
                  set(PROJECT_SOURCES
                          MyTestApp.h
                          MyTestApp.cpp
                          OgreApplicationContextQt.cpp
                          main.cpp
                  )
                  
                  if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
                      qt_add_executable(BootstrapCMakeQt5Cpp
                          ${PROJECT_SOURCES}
                      )
                  else()
                      if(ANDROID)
                          add_library(BootstrapCMakeQt5Cpp SHARED
                              ${PROJECT_SOURCES}
                          )
                      else()
                          add_executable(BootstrapCMakeQt5Cpp
                              ${PROJECT_SOURCES}
                          )
                      endif()
                  endif()
                  
                  #find_package(ZLIB REQUIRED)
                  add_library(ZLIB::ZLIB INTERFACE IMPORTED)
                  add_library(SDL2::SDL2 INTERFACE IMPORTED)
                  find_package(OGRE REQUIRED COMPONENTS Bites RTShaderSystem CONFIG)
                  
                  target_link_libraries(BootstrapCMakeQt5Cpp PRIVATE Qt${QT_VERSION_MAJOR}::Widgets OgreBitesQt OgreRTShaderSystem)
                  

                  MyTestApp.h

                  #ifndef MYTESTAPP_H
                  #define MYTESTAPP_H
                  
                  #include "Ogre.h"
                  #include "OgreApplicationContextQt.h"
                  #include <QtCore/QObject>
                  
                  class MyTestApp : public OgreBites::ApplicationContextQt, public OgreBites::InputListener
                  {
                      Q_OBJECT
                  public:
                      MyTestApp();
                      virtual ~MyTestApp() { }
                      void setup();
                      bool keyPressed(const OgreBites::KeyboardEvent& evt);
                  };
                  
                  #endif // MYTESTAPP_H
                  

                  MyTestApp.cpp

                  #include "MyTestApp.h"
                  
                  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();
                  
                  }
                  

                  main.cpp

                  #include <QGuiApplication>
                  #include "MyTestApp.h"
                  
                  int main(int argc, char *argv[])
                  {
                      QGuiApplication qapp(argc, argv);
                      MyTestApp app;
                      app.initApp();
                      app.getRoot()->startRendering();
                      app.closeApp();
                      return qapp.exec();
                  }
                  
                  1 Reply Last reply
                  0
                  • timob256T Offline
                    timob256T Offline
                    timob256
                    wrote on last edited by
                    #14

                    this my answer

                    https://ru.stackoverflow.com/questions/1357826/как-установить-ogre3d-из-исходников-в-линуксе

                    8Observer88 1 Reply Last reply
                    0
                    • timob256T timob256

                      this my answer

                      https://ru.stackoverflow.com/questions/1357826/как-установить-ogre3d-из-исходников-в-линуксе

                      8Observer88 Offline
                      8Observer88 Offline
                      8Observer8
                      wrote on last edited by 8Observer8
                      #15

                      @timob256 but I use Windows

                      1 Reply Last reply
                      1
                      • JoeCFDJ Offline
                        JoeCFDJ Offline
                        JoeCFD
                        wrote on last edited by JoeCFD
                        #16

                        Component Bites is missing. Are you sure you added its lib?

                        1 Reply Last reply
                        0
                        • C Offline
                          C Offline
                          cpr0gr4mm3r
                          wrote on last edited by
                          #17

                          I use Ogre 13.6.3 and Qt 5.15.2 MinGW 64-bit and I have the same problem.

                          Did you get a solution?

                          8Observer88 3 Replies Last reply
                          0
                          • C cpr0gr4mm3r

                            I use Ogre 13.6.3 and Qt 5.15.2 MinGW 64-bit and I have the same problem.

                            Did you get a solution?

                            8Observer88 Offline
                            8Observer88 Offline
                            8Observer8
                            wrote on last edited by
                            #18
                            This post is deleted!
                            1 Reply Last reply
                            0
                            • C cpr0gr4mm3r

                              I use Ogre 13.6.3 and Qt 5.15.2 MinGW 64-bit and I have the same problem.

                              Did you get a solution?

                              8Observer88 Offline
                              8Observer88 Offline
                              8Observer8
                              wrote on last edited by
                              #19
                              This post is deleted!
                              1 Reply Last reply
                              0
                              • C cpr0gr4mm3r

                                I use Ogre 13.6.3 and Qt 5.15.2 MinGW 64-bit and I have the same problem.

                                Did you get a solution?

                                8Observer88 Offline
                                8Observer88 Offline
                                8Observer8
                                wrote on last edited by 8Observer8
                                #20

                                @cpr0gr4mm3r Maybe my next topic will help you: Problems with Ogre in Qt Creator

                                1 Reply Last reply
                                0

                                • Login

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