How to build OGRE in Ubuntu

Ubuntu ships with a particular version of OGRE that can be installed easily. For example, on Ubuntu 16.04:

$ sudo apt install libogre-1.9-dev

However, if you need to use an older or newer version of OGRE then you might need to build it yourself. This is not so hard on Linux, as it is on Windows.

  • Install the essential packages needed for building OGRE:
$ sudo apt install build-essential automake libtool libfreetype6-dev libfreeimage-dev libzzip-dev libxrandr-dev libxaw7-dev freeglut3-dev libgl1-mesa-dev libglu1-mesa-dev libpoco-dev libtbb-dev doxygen libcppunit-dev
  • Download the OGRE version you want as a ZIP file from its Mercurial repository on Bitbucket here.

  • Unzip the file and build OGRE:

$ mkdir build
$ cd build
$ cmake ..
$ make
  • To install OGRE to /usr/local/lib/OGRE:
$ sudo make install

Tried with: OGRE 1.8 and Ubuntu 16.04

Advertisements

Could not load OGRE dynamic library

Problem

I had an binary compiled on Ubuntu 14.04. I tried to run it on Ubuntu 16.04 and got this error:

OGRE EXCEPTION(7:InternalErrorException): Could not load dynamic library /usr/lib/x86_64-linux-gnu/OGRE-1.8.0/RenderSystem_GL

Solution

From the error, I could see that it was looking for an OGRE library file. I installed the OGRE library available on Ubuntu 16.04:

$ sudo apt install libogre-1.9-dev

The error still persisted, because Ubuntu 16.04 only has OGRE 1.9, while this binary was looking for OGRE 1.8 library files.

I tried to create a symbolic link of an OGRE 1.8 directory to the existing OGRE 1.9 directory:

$ cd /usr/lib/x86_64-linux-gnu/
$ ln -s OGRE-1.9.0 OGRE-1.8.0

This worked! The executable ran without problems. This saved me from having to build OGRE 1.8 from source on this computer.

How to generate documentation for OGRE

You can get OGRE source code from Bitbucket or from its source package. OGRE uses Doxygen to generate its API documentation. The Doxygen configuration file is html.cfg.

To generate OGRE documentation using Doxygen:

$ cd Docs
$ doxygen src/html.cfg

The main HTML documentation page will be stored in Docs/api/html/index.html

Tried with: OGRE 1.9 and Ubuntu 14.04

OGRE build error: freetype package could not be located

FreeType error in CMake GUI
FreeType error in CMake GUI

Problem

I was trying to build OGRE on Ubuntu:

$ mkdir build
$ cd build
$ cmake ..

CMake threw this error:

CMake Error at CMake/Utils/MacroLogFeature.cmake:100 (MESSAGE):
  -----------------------------------------------------------------------------
  -- The following REQUIRED packages could NOT be located on your system.
  -- Please install them before continuing this software installation.
  -- If you are in Windows, try passing -DOGRE_DEPENDENCIES_DIR=<path to dependencies>
  -----------------------------------------------------------------------------
  + freetype: Portable font engine <http://www.freetype.org>

CMake complained that it could not find the FreeType package. But, I had already installed both the libfreetype6 and libfreetype6-dev packages.

Solution

The dependency on FreeType is listed in the CMake/Dependencies.cmake file in the OGRE source. OGRE seems to be using its own CMake script to find FreeType located at CMake/Packages/FindFreetype.cmake. This script seems to be failing to locate some file or directory of FreeType, even though it is installed.

I solved this by opening the CMake GUI:

$ cmake-gui ..

Enable Advanced and Grouped so that its easy to view the results. Click Configure. The same FreeType error is thrown up. But, now we can see that for some reason the FREETYPE_INCLUDE_DIR is not being found. I set this to /usr/include/freetype2. Click Configure again and the error is gone. Then click Generate. Compilation worked fine after this.

Tried with: OGRE 1.8 and Ubuntu 14.04

Log levels in OGRE

There are 3 logging levels that can be specified in OGRE. These can be seen in the OgreMain/include/OgreLog.h file:

/** The level of detail to which the log will go into.
*/
enum LoggingLevel
{
    LL_LOW = 1,
    LL_NORMAL = 2,
    LL_BOREME = 3
};

There are 3 types of log messages that can be asked to be logged. These are also seen in OgreMain/include/OgreLog.h file:

/** The importance of a logged message.
*/
enum LogMessageLevel
{
    LML_TRIVIAL = 1,
    LML_NORMAL = 2,
    LML_CRITICAL = 3
};

How to use OgreXmlConverter to convert binary and XML formats

A OGRE mesh can be used to store a skeleton, mesh, materials and scene information. The skeleton and mesh information can quite large and hence they are typically stored in the OGRE binary format. If you would like to view the internal values, there is an alternate OGRE XML format that is supported too. The OgreXmlConverter tool can be used to convert the skeleton and mesh files between the binary and XML formats.

To install the OgreXmlConverter:

$ sudo apt install ogre-1.8-tools

To convert a skeleton from binary to XML format:

$ OgreXmlConverter foo.skeleton foo.skeleton.xml

To convert a mesh from XML to binary format:

$ OgreXmlConverter foo.mesh.xml foo.mesh

Tried with: OGRE 1.8.0 and Ubuntu 14.04

How to build OGRE on Windows

OGRE is a bit difficult to compile on Windows because of the many libraries it depends on.

Build OGRE dependencies

  • Clone the OGRE Dependencies repository. This has the source code of all the OGRE dependent libraries.

  • Build it using CMake. Make sure you set CMAKE_INSTALL_PREFIX to a separate subdirectory since this path will be used while building OGRE.

  • If you get error on unistd.h, comment that line. I found it could build without using it.

Build OGRE

  • Download the source code of OGRE or clone from its repository.

  • Build it using CMake. Set the variable OGRE_DEPENDENCIES_DIR to the install path you set while building the dependencies. Set the CMAKE_INSTALL_PREFIX variable to the place where you want the OGRE libraries and executables need to be placed after build.

Pre-built

Pre-built libraries of OGRE for recent Visual Studio versions can be downloaded from here.

Reference

Tried with: OGRE 1.8.1, Visual Studio 2013 and Windows 7 x64

How to convert from Blender to OGRE format

Blender does not ship with support for exporting to OGRE mesh and skeleton. However, the Blender2OGRE addon can be used to export a Blender file as OGRE mesh, skeleton and material files.

  1. Download or clone the Blender2OGRE addon repository https://bitbucket.org/MindCalamity/blender2ogre

  2. Make sure that your Blender version is equal or greater than what is required by Blender2OGRE. You can find the minimum version required listed in the bl_info dictionary in the file io_export_ogreDotScene.py. If you are using a version of Blender that is older than what is required, then install a new version.

  3. Open Blender and go to File > User Preferences > Addons > Install from file. Choose the file io_export_ogreDotScene.py from the files you downloaded. Once the addon is added, it will appear as Import-Export: OGRE Exporter and RealXtend. Remember to enable the addon.

  4. If the addon was installed and enabled correctly, you must be able to see a Ogre checkbox at the right in the top toolbar. If your window width is small, you may have to move the top toolbar to the right by pressing and holding the middle mouse button.

  5. Open the model you wish to export. Choose File > Export > OGRE3D. By default, the addon exports mesh, skeleton, texture and material files. Both XML and binary versions of the OGRE mesh are created. You can test if the export worked, by opening the .mesh file using OGREMeshy.

Tried with: Blender 2.69 and Ubuntu 12.04 LTS

How to view OGRE mesh file

The OGRE library uses a custom mesh format to represent and render 3D objects. These files are stored with a file extension of .mesh and can be read and displayed by the library. But sometimes you may want to have a look at the mesh files in isolation to view it in wireframe or with surface rendering. The OGRE Meshy program can be used to view OGRE mesh files.

Install

Installing OGRE Meshy on Ubuntu is easy. Go to its Sourceforge page and download the pre-built program for Kubuntu64. Unzip the contents and type the command: make ubuntu_install

Usage

To use the program from the shell, type ogremeshy. This opens the mesh viewer. Open the mesh file that you want from here. You can view the mesh better by displaying the axes, bones, wireframe and bounding box in the program.

Tried with: OGRE Meshy 1.5, OGRE 1.7.4 and Ubuntu 12.04 LTS