How to install OGRE in Linux

For a couple of days now, I have been working with OGRE on Open Morrowind (OpenMW) project, trying to accomplish my task as a C++ developer. However, before I started writing a single line of code, I had to setup the programming environment first. So, I went over OpenMW wiki in order to find its dependencies and make sure they have been installed onto my system. OGRE SDK, was one of them; not installed yet in my PC.

Running Ubuntu, I thought it would be an easy task but I was wrong… so here’s the “how to” to install OGRE SDK, that so how to compile it from source. Even though we are aware that compiling is not recommended in Ubuntu, in this particular program is vital to do so.

Find Dependencies

First things first, you need to have all the necessary programs installed to compile OGRE into Linux. Please follow the instructions below based in your Linux distribution: Ubuntu, Fedora, OpenSuSE, Arch.

sudo apt-get install build-essential automake libtool libfreetype6-dev libfreeimage-dev libzzip-dev libxrandr-dev libxaw7-dev freeglut3-dev libgl1-mesa-dev libglu1-mesa-dev libxt-dev libpng12-dev libglew1.6-dev

yum install @development-tools
yum install cmake openal-soft-devel bullet-devel ois-devel ogre-devel libblkid-devel boost-devel qt-devel libsndfile-devel zziplib-devel freetype-devel libXaw-devel libXrandr-devel libXxf86vm-devel libGLU-devel freeimage-devel openexr-devel glew-devel tinyxml-devel tbb cppunit-devel git

Next in order to install nVIDIA Computer Graphics Toolkit and mpg123, we need access to RPMFusion repository. If you don’t know how to enable it or it’s your first time, follow RPMFusion’s instructions. Once you have RPMFusion both repositories (free and non-free) fully installed, please type:

yum install Cg libmpg123-devel

First you are going to need the Game’s repo from unstable branch of OpenSUSE (aka Factory)

zypper ar games

then, you are able to install the dependencies:

zypper in gcc-c++ libXaw-devel freetype2-devel freeimage-devel libxrandr-devel zziplib-devel cmake boost-devel libOIS-devel cg-devel doxygen cppunit-devel

Things are more straight forward here, so there’s just one command to follow:

pacman -S boost-libs boost freeimage freetype2 libxaw libxrandr mesa nvidia-cg-toolkit ois zziplib cmake gcc

Download source

Secondly you have to download the OGRE SDK source code from SourceForge. You can always use GUI tools, like a web browser and a File Archiver, while if you are more of an old-school Linux guy, try wget and tar -xvzf command line tools.

Build/Compile from source

Once you have extracted OGRE into /home dir, then go in that folder in terminal way. Pay attention that in the following example, I have downloaded OGRE 1.8.1 version, thus the name scheme applying is ogre_src_v1-8-1.

cd ogre_src_v1-8-1/

Create and empty directory called whatever you want (I prefer Build) and get in.

mkdir Build
cd Build

Now it’s time to actually Build our source code using cmake. Hopefully, if you have all the dependencies installed properly you won’t have any troubles, right.

cmake ..
make -j`getconf _NPROCESSORS_ONLN`
sudo make install

Note that “getconf _NPROCESSORS_ONLN” stands for the active CPU threads. Simply put, the -j2 specifies how many parallel compilation jobs to run. Substitute the number of processor cores on your system, e.g. -j2 for a dual-core, -j4 for a quad core… if you have HyperThreading enabled, you can double the value.

Alternative: using Code::Blocks

You need to build codeblock’s associated files using cmake. Then open the project and follow OGRE’s wiki guide.

cmake -G “CodeBlocks – Unix Makefiles” ..

 Alternative: using KDevelop

Kdevelop4 is very nice, easy-to-use and modern IDE. After getting source, just open Kdevelop and click “Project -> Open/Import Project…” and show path to code (~/ogre_src_v1-8-1). You will have to choose build folder (eg /home/drpaneas/ogre_src_v1-8-1/build). Then wait a little bit for KDevelop to load and index the project files.

For building click on button “Build Selection”. For running click “Execute”. Running first time “Launch Configurations” will pop up. You have to set executable file by selecting “ogre_src_v1-8-1″, clicking “+” icon and choosing under (Launch Configuration) Executable “/home/drpaneas/ogre_src_v1-8-1/build/bin/SampleBrowser_d” as “Project Target”.Then Run it (Shift+F9).

More info at OGRE’s wiki here.

Alternative: using Eclipse

Select “C/C++ / Makefile project with existing code” as project type. In “Existing code location”, click browse, and again, select openmw’s folder. Also select “Linux GCC” as toolchain, then click “Finish”.Now right-click on your project, and select “Properties”. Go to “C/C++ build”, uncheck “use default build command”, and specify your command, like: (CoreDuo -j2, QuadCore -j4)

make -j 4 -C ${ProjDirPath}../build

In case you have problems with Eclipse, try to fix the includes (Eclipse complaining about Ogre and Bullet). Go to project properties, “C/C++ General”, “Paths and symbols”, select “GNU C++”.

Click the “add” button to add the following paths :

/usr/include/OGRE and  /usr/include/bullet

Alternative: using Qt4

Things can be quite helpful in Qt4 after seeing the screenshots, so please follow the link to OGRE’s wiki page.


That’s it. Now you are able to launch the SampleBrowser, located at /Build/bin/ directory at your OGRE project.