Qt + Ogre3D. I cannot build a very simple example
-
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:
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(); }
-
I added OgreApplicationContextQt.cpp directly in my code:
I added Q_OBJECT to MyTestApp.h. I have a little different errors:
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
-
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'
andundefined reference to 'compress'
in OgreSTBICodec.cpp:I added OgreApplicationContextQt.cpp to the project:
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(); }
-
-
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?
-
This post is deleted!
-
This post is deleted!
-
@cpr0gr4mm3r Maybe my next topic will help you: Problems with Ogre in Qt Creator