Ogre Version: 13.6.3
Operating System: Windows 10 Home
Render System: DirectX 12
Hi all,
I am using Qt 5.15.2 MinGW 64-bit and Im trying to build the next source:
main.cpp
Code: Select all
#include "ogrewindow.h"
#include <QApplication>
int main(int argc, char *argv[])
{
QApplication a(argc, argv);
OgreWindow w;
w.show();
return a.exec();
}
ogrewindow.h
Code: Select all
#ifndef OGREWINDOW_H
#define OGREWINDOW_H
#include <QWindow>
/*
Ogre3D header
*/
#include <Ogre.h>
#include <OgreApplicationContextQt.h>
QT_BEGIN_NAMESPACE
namespace Ui { class OgreWindow; }
QT_END_NAMESPACE
class OgreWindow : public QWindow
{
Q_OBJECT
public:
OgreWindow(QWindow *parent = nullptr);
~OgreWindow();
private:
Ui::OgreWindow *ui;
};
#endif // OGREWINDOW_H
ogrewindow.cpp
Code: Select all
#include "ogrewindow.h"
#include "ui_ogrewindow.h"
#include "ogreapplication.h"
OgreWindow::OgreWindow(QWindow *parent)
: QWindow(parent)
{
OgreApplication* ogreApplication = new OgreApplication();
ogreApplication->injectMainWindow(this);
ogreApplication->initApp();
}
OgreWindow::~OgreWindow()
{
delete ui;
}
ogreapplication.h
Code: Select all
#ifndef OGREAPPLICATION_H
#define OGREAPPLICATION_H
#include <Ogre.h>
#include <OgreApplicationContextQt.h>
class OgreApplication: public OgreBites::ApplicationContextQt, public OgreBites::InputListener
{
public:
OgreApplication();
~OgreApplication();
bool keyPressed(const OgreBites::KeyboardEvent& evt);
bool mouseMoved(const OgreBites::MouseMotionEvent& evt);
bool mousePressed(const OgreBites::MouseButtonEvent& evt);
bool mouseReleased(const OgreBites::MouseButtonEvent& evt);
void setup();
Ogre::SceneNode* m_node;
};
#endif // OGREAPPLICATION_H
ogreapplication.cpp
Code: Select all
#include "ogreapplication.h"
OgreApplication::OgreApplication(): ApplicationContextQt("Tutorial Application")
{
ApplicationContextQt::setup();
Ogre::Root* root = getRoot();
Ogre::SceneManager* scnMgr = root->createSceneManager();
}
void OgreApplication::setup()
{
// do not forget to call the base first
OgreBites::ApplicationContextQt::setup();
}
I set the C:\ogre-13.6.3\build\sdk\CMake value to OGRE_DIR variable in CMake section of Qt Creator.
This is my CMakeLists.txt
Code: Select all
cmake_minimum_required(VERSION 3.5)
project(untitled VERSION 0.1 LANGUAGES CXX)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTORCC ON)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(OgreFolder C:\\ogre-13.6.3\\build\\sdk)
find_package(OGRE REQUIRED COMPONENTS Bites RTShaderSystem CONFIG)
find_package(QT NAMES Qt6 Qt5 REQUIRED COMPONENTS Widgets)
find_package(Qt${QT_VERSION_MAJOR} REQUIRED COMPONENTS Widgets)
if(OGRE_STATIC)
find_package(ZLIB REQUIRED)
# merely silence cmake, we wont use it
add_library(SDL2::SDL2 INTERFACE IMPORTED)
endif()
set(PROJECT_SOURCES
main.cpp
ogreapplication.cpp
ogreapplication.h
ogrewindow.cpp
ogrewindow.h
ogrewindow.ui
)
if(${QT_VERSION_MAJOR} GREATER_EQUAL 6)
qt_add_executable(untitled
MANUAL_FINALIZATION
${PROJECT_SOURCES}
)
# Define target properties for Android with Qt 6 as:
# set_property(TARGET untitled APPEND PROPERTY QT_ANDROID_PACKAGE_SOURCE_DIR
# ${CMAKE_CURRENT_SOURCE_DIR}/android)
# For more information, see https://doc.qt.io/qt-6/qt-add-executable.html#target-creation
else()
if(ANDROID)
add_library(untitled SHARED
${PROJECT_SOURCES}
)
# Define properties for Android with Qt 5 after find_package() calls as:
# set(ANDROID_PACKAGE_SOURCE_DIR "${CMAKE_CURRENT_SOURCE_DIR}/android")
else()
add_executable(untitled
${PROJECT_SOURCES}
)
endif()
endif()
target_link_libraries(untitled PRIVATE Qt${QT_VERSION_MAJOR}::Widgets ${OgreFolder}\\lib\\libOgreBites.dll.a ${OgreFolder}\\lib\\libOgreMain.dll.a ${OgreFolder}\\lib\\libOgreRTShaderSystem.dll.a)
target_include_directories(untitled PRIVATE ${OgreFolder}\\include\\OGRE ${OgreFolder}\\include\\OGRE\\Bites ${OgreFolder}\\include\\OGRE\\RTShaderSystem)
set_target_properties(untitled PROPERTIES
MACOSX_BUNDLE_GUI_IDENTIFIER my.example.com
MACOSX_BUNDLE_BUNDLE_VERSION ${PROJECT_VERSION}
MACOSX_BUNDLE_SHORT_VERSION_STRING ${PROJECT_VERSION_MAJOR}.${PROJECT_VERSION_MINOR}
MACOSX_BUNDLE TRUE
WIN32_EXECUTABLE TRUE
)
install(TARGETS untitled
BUNDLE DESTINATION .
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR})
if(QT_VERSION_MAJOR EQUAL 6)
qt_finalize_executable(untitled)
endif()
I get the next errors:
Code: Select all
C:\ogre-13.6.3\build\sdk\include\OGRE\Bites\OgreApplicationContextQt.h:41: error: undefined reference to `__imp__ZTVN9OgreBites20ApplicationContextQtE'
CMakeFiles/untitled.dir/ogreapplication.cpp.obj: In function `OgreBites::ApplicationContextQt::ApplicationContextQt(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
C:/ogre-13.6.3/build/sdk/include/OGRE/Bites/OgreApplicationContextQt.h:41: undefined reference to `__imp__ZTVN9OgreBites20ApplicationContextQtE'
C:\ogre-13.6.3\build\sdk\include\OGRE\Bites\OgreApplicationContextQt.h:41: error: undefined reference to `__imp__ZTVN9OgreBites20ApplicationContextQtE'
C:\ogre-13.6.3\build\sdk\include\OGRE\Bites\OgreApplicationContextQt.h:36: error: undefined reference to `__imp__ZTVN9OgreBites20ApplicationContextQtE'
CMakeFiles/untitled.dir/ogreapplication.cpp.obj: In function `OgreBites::ApplicationContextQt::~ApplicationContextQt()':
C:/ogre-13.6.3/build/sdk/include/OGRE/Bites/OgreApplicationContextQt.h:36: undefined reference to `__imp__ZTVN9OgreBites20ApplicationContextQtE'
C:\ogre-13.6.3\build\sdk\include\OGRE\Bites\OgreApplicationContextQt.h:36: error: undefined reference to `__imp__ZTVN9OgreBites20ApplicationContextQtE'
C:\Users\user\Documents\untitled\ogreapplication.cpp:-1: error: undefined reference to `vtable for OgreApplication'
:-1: error: collect2.exe: error: ld returned 1 exit status
:-1: error: ninja: build stopped: subcommand failed.
What is missing?