History: Setting Up An Application - QtCreator
Preview of version: 12
|
|
Setting Up An Application With QtCreator |
Introduction
This set of instructions will walk you through setting up a QtCreator C++ project from scratch.
When you have finished this tutorial you will be able to compile a working Ogre Application and you will be ready to start the Basic Tutorials.
Table of contents
Prerequisites
Get QtCreator from Qt.Nokia.
Get the stable version or the latest snapshot.
New Project
Click New Project in the start screen, and choose Other Project - Empty project.
Give it a name and a place:
Add files:
Files added:
Options:
Qt4 Settings:
Edit project file:
TEMPLATE = app TARGET = OgreQtProject DEFINES -= UNICODE CONFIG -= qt unix { # You may need to change this include directory INCLUDEPATH += /usr/include/OGRE CONFIG += link_pkgconfig PKGCONFIG += OGRE } win32 { LIBS *= user32.lib LIBS += -L$(OGRE_HOME)\\boost\\lib release:LIBS += -L$(OGRE_HOME)\\lib\\release debug:LIBS += -L$(OGRE_HOME)\\lib\\debug INCLUDEPATH += $(OGRE_HOME)\\include INCLUDEPATH += $(OGRE_HOME)\\include\\OIS INCLUDEPATH += $(OGRE_HOME)\\include\\OGRE INCLUDEPATH += $(OGRE_HOME)\\boost } debug { TARGET = $$join(TARGET,,,d) LIBS *= -lOgreMain_d -lOIS_d } release:LIBS *= -lOgreMain -lOIS HEADERS += \ TutorialApplication.h \ BaseApplication.h SOURCES += \ TutorialApplication.cpp \ BaseApplication.cpp
Build All:
Build Configuration:
Custom Process Step settings:
Run Settings:
New Run Configuration:
Prerequisites (for latest version)
You will need the latest Qt SDK available on the Qt website. (Right now, it's the "Qt SDK version 1.2.1" and containing (default on SDK) Qt v.4.8.1)
The latest version of OGRE3D will be needed too and can be found on the OGRE website. (Actually, using version 1.8.0)
Everything in the next steps aiming at setting up an OGRE project will work using MinGW (as my Qt install does), so, let's download it from the MinGW's project website.
Next step, we'll set up the environment to be able to use all that we've just downloaded.
Environment set-up
First thing to do, if that's not done yet, is to install the Qt SDK, just follow the installation program, there isn't so much difficulties.
If you'd installed it a long time ago, then just update it to the last version using the "Maintenance Tool" that's delivered with the package.
There things will get a bit harder, and i hope that all will seems to be clear for you.
1 - You'll have install the OGRE SDK into the Qt directory, by merging this folder with Qt installation, it'll allow Qt to use easily auto-completion while programming with OGRE, and simplify some linking steps.
1-a) Extract the OGRE SDK into your Qt installation, the path is installationRootDirectory\Desktop\Qt\4.8.1\mingw (for exemple, the full path for me is C:\QtSDK\Desktop\Qt\4.8.1\mingw ).
There, when finished, some directories should have merged (don't worry, there is no risks of erasing a data from Qt with OGRE), and these folders should be visibles:
- bin
- - debug
- - release
- boost
- - boost
- - lib
- CMake
- Docs
- include
- - OGRE
- - OIS
- lib
- - debug
- - release
- media
- Samples
And few other files as:
- BuildSamples.bat
- BuildSamples.txt
- CMakeLists.txt
"bin" is the directory where you will find two other directories named "debug" and "release" where are all the dlls needed to run an OGRE Project (yeah, you know, these files you have to join with your binary to avoid some critical error about missing library ๐) All the other things in this directory are parts of Qt.
"boost". Ahh.. The first big work to achieve to get prepared for something working. In this directory, are two sub-directories: "boost" and "lib", please cut/paste the "lib" directory content to "lib" directory of this parent directory (the one where you can found all the directories i listed earlier) and the second "boost" directory into the "include/OGRE" directory (and not just it content, otherwise, you won't be able to compile OGRE correctly later).
"include" is the directory that contains all includes of OGRE, and Qt. OGRE's includes are in the sub-folder of the same name, OIS is the one for.. OIS (Output/Input System). There aren't heavy changes to do there. Just to paste the "boost" sub-directory from the "boost" directory at the 4.8.2 "root" system.
"lib" is one of the more important directory; There will be the files representing the libraries and fulfilling the code with their functions. The only change to do there, is to copy there the "boost/lib" content in it.
I won't talk about the other directories, they're less usefull there, i just putted them all that you can have an anchor to get attached to while proceding to these modifications ๐.
Now that your Qt is ready and prepared with the OGRE system, you can install MinGW (it's more the way to get the latest version than anything else).
When installing, change the install directory by the mingw one into your Qt installation (for example C:\QtSDK\mingw on my computer). Say "yes" when it ask for overwrite, or says that there is already a folder with this name.
The latest things to do, is to create a point reference to your OGRE "home" system into your path (will be used into .pro files to make them shorter to write and allow them to be more "cross-platform" or able to be used by everybody. ๐ )
To do so; hit ctrl+R, it'll open a box. Write "cmd" (without quotes of course) in the field and press enter, this will open a prompt command.
Then, type the following command replacing "pathtoQtSDK" with your Qt installation directory.
setx OGRE_HOME pathToQtSDK\Desktop\Qt\4.8.1\mingw\
For my Qt installation, I typed this command:
setx OGRE_HOME C:\QtSDK\Desktop\Qt\4.8.1\mingw\
Congratz! Your Environment has been set up to create an OGRE Project with QtCreator.
Project creation and configuration
Create a new project by hitting CTRL+N, then in the new window, select "Other project" in the left-top column and "Empty Qt project" in the right one.
Choose your name project and set it path then press "Next" twice and Finish.
Then, you'll need to link up the libraries with the compiler, here you have to configure the .pro file.
TEMPLATE = app TARGET = OgreQtProject #Depends of your name project of course ^^ DEFINES -= UNICODE CONFIG -= qt CONFIG += console unix { #You may need to change this include directory to fit your configuration INCLUDEPATH += /user/include/OGRE CONFIG += link_pkgconfig PKGCONFIG += OGRE } win32 { LIBS += -L$(OGRE_HOME)\\lib\\ -luser32.lib LIBS += -L$(OGRE_HOME)\\boost\\lib INCLUDEPATH += $(OGRE_HOME)\\include\\OIS INCLUDEPATH += $(OGRE_HOME)\\include\\OGRE INCLUDEPATH += $(OGRE_HOME)\\boost } CONFIG(debug, debug|release) { #It's possible to link the files directly, but it's longer, you just need to use the couple -L -l to link each library #LIBS += $(OGRE_HOME)\\lib\\debug\\libOgreMain_d.dll.a $(OGRE_HOME)\\lib\\debug\\libOIS_d.dll.a LIBS += -L$(OGRE_HOME)\\lib\\debug\\ -llibOgreMain_d LIBS += -L$(OGRE_HOME)\\lib\\debug\\ -llibOIS_d } CONFIG(release, debug|release) { LIBS += -L$(OGRE_HOME)\\lib\\release\\ -llibOgreMain LIBS += -L$(OGRE_HOME)\\lib\\release\\ -llibOIS }
After that, you should be able to compile or make a Qmake without getting any error. Enjoy next parts of the tutorial on QtCreator !
Tutorial Framework
Tutorial Framework:
Download the Ogre Wiki Tutorial Framework here:
No such attachment on this page
Project Configuration