Skip to main content

History: Setting Up An Application - QtCreator

Source of version: 17

Copy to clipboard
            {DIV(class="Layout_box6")}{SPLIT(colsize=15%|85%)}{img fileId="1919"}---
{DIV(class="bigBold")}Setting Up An Application With QtCreator{DIV}{SPLIT}
{DIV}
%clear%
!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)).

{maketoc}

!Prerequisites
Get QtCreator from Qt.Nokia.
Get the [http://qt.nokia.com/downloads|stable version] or [ftp://ftp.trolltech.com/qtcreator/snapshots/latest|the latest snapshot].

!New Project
Click New Project in the start screen, and choose Other Project - Empty project.
{img fileId="1909"}
Give it a name and a place:
{img fileId="1910"}
Add files:
{img fileId="1911"}
Files added:
{img fileId="1907"}
Options:
{img fileId="1908"}
Qt4 Settings:
{img fileId="1912"}
Edit project file:
{img fileId="1913"}
{CODE(wrap="1", colors="qmake")}
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
{CODE}

Build All:
{img fileId="1914"}
Build Configuration:
{img fileId="1918"}

Custom Process Step settings:
{img fileId="1915"}
Run Settings:
{img fileId="1917"}
New Run Configuration:
{img fileId="1916"}

!Prerequisites (for latest version)
You will need the latest Qt SDK available on the [http://qt.nokia.com/downloads|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 [http://www.ogre3d.org/download/sdk|OGRE website]. (Actually, using version 1.8.0)

An other lib is needed: user32.lib, you can download it here: [http://web.lemoyne.edu/courseinformation/CourseInformation/New%20Folder/PCOBOL32/user32.lib]

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 [http://sourceforge.net/projects/mingw/|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. You've to copy the user32.lib there too.

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.

{CODE(wrap="1", colors="winbash")}setx OGRE_HOME pathToQtSDK/Desktop/Qt/4.8.1/mingw{CODE}

For my Qt installation, I typed this command: 

{CODE(wrap="1", colors="winbash")}setx OGRE_HOME C:/QtSDK/Desktop/Qt/4.8.1/mingw{CODE}

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.

{CODE(wrap="1", colors="qmake")}
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 += $(OGRE_HOME)/lib/user32.lib
    LIBS += -L$(OGRE_HOME)/boost/lib
    INCLUDEPATH += $(OGRE_HOME)/include/OIS
    INCLUDEPATH += $(OGRE_HOME)/include/OGRE
}

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 += $(OGRE_HOME)/lib/debug/libOgreMain_d.dll.a
    LIBS += $(OGRE_HOME)/lib/debug/libOIS_d.dll.a
}

CONFIG(release, debug|release) {
    LIBS += $(OGRE_HOME)/lib/release/libOgreMain.dll.a
    LIBS += $(OGRE_HOME)/lib/release/libOIS.dll.a
}

SOURCES += \
    main.cpp \
    mainwindow.cpp

HEADERS += \
    mainwindow.h

{CODE}

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:
{img fileId="1657" width="400" thumb="y" alt="" rel="box"}
Download the ((Ogre Wiki Tutorial Framework)) here:
{ATTACH(id="61", page="Ogre Wiki Tutorial Framework",icon="1")}{ATTACH}

!Project Configuration

{TRANSCLUDE(page="seebox")}
[http://blog.codeimproved.net/2009/12/qtcreator-tips-and-tricks/|QtCreator Tips and Tricks]
{TRANSCLUDE}


        

History

Information Version
Sun 22 of Sep, 2013 12:54 GMT-0000 Flateno Added arguments to the Release qmake build step. Also did some cleanup of the layout. 32
Sun 22 of Sep, 2013 12:21 GMT-0000 Flateno Added OgreOverlay.lib to the pro-file, as needed in Ogre 1.9 31
Sun 22 of Sep, 2013 12:16 GMT-0000 Flateno A minor addition to the Run Configuration 30
Sun 22 of Sep, 2013 12:11 GMT-0000 Flateno Minor addition to Custom Process Step 29
Sun 22 of Sep, 2013 11:38 GMT-0000 Flateno A small addition to the .pro file for Ogre 1.9 users 28
Sun 22 of Sep, 2013 11:27 GMT-0000 Flateno Minor tip for settings in Qt 5 27
Sun 22 of Sep, 2013 11:19 GMT-0000 Flateno Added tip when adding files to project 26
Sat 21 of Sep, 2013 21:35 GMT-0000 Flateno Changed url from qt nokia to http://qt-project.org/. 25
Sun 27 of May, 2012 23:50 GMT-0000 jacmoe [rollback version 9] 24
Tue 31 of Jul, 2012 00:22 GMT-0000 Erio 23
Tue 31 of Jul, 2012 00:19 GMT-0000 Erio 22
Tue 31 of Jul, 2012 00:18 GMT-0000 Erio 21
Mon 23 of Jul, 2012 10:31 GMT-0000 Erio 20
Mon 23 of Jul, 2012 10:30 GMT-0000 Erio Improved the previous description of the .pro file 19
Fri 20 of Jul, 2012 09:54 GMT-0000 Erio 18
Fri 20 of Jul, 2012 06:23 GMT-0000 Erio 17
Fri 20 of Jul, 2012 06:22 GMT-0000 Erio 16
Thu 19 of Jul, 2012 16:03 GMT-0000 Erio 15
Thu 19 of Jul, 2012 16:02 GMT-0000 Erio 14
Thu 19 of Jul, 2012 15:59 GMT-0000 Erio Update of the .pro code 13
Thu 19 of Jul, 2012 03:33 GMT-0000 Erio 12
Thu 19 of Jul, 2012 03:30 GMT-0000 Erio Finished to paste the code for version 4.8.1 Qt and QtCreator and OGRE 1.8.0 PS: if there are any change to be done, tell me, i hope that i'm doing right, but i may be wrong ... 11
Thu 19 of Jul, 2012 03:02 GMT-0000 Erio Added a first part about setting up an OGRE project with Qt 4.8.1, QtCreator 2.4.1 and OGRE3D 1.8.0 PS: I didn't wanted to delete anything was made before, so i just made a new part :) and I'm sorry i 10
Sun 27 of May, 2012 23:50 GMT-0000 jacmoe 9
Sun 27 of May, 2012 23:41 GMT-0000 jacmoe 8
  • «
  • 1 (current)
  • 2