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
$ mkdir build
$ cd build
$ cmake ..
- To install OGRE to
$ sudo make install
Tried with: OGRE 1.8 and Ubuntu 16.04
Ubuntu tends to ship an old version of Boost. New versions of this library are released regularly. Thankfully, it is pretty easy to build and use Boost on Linux:
$ sudo apt install libicu-dev
- The program used to generate the build configuration and compilation script is
bootstrap.sh. You can check what options it takes as input using its
--help argument. At the very least, we need to specify the
--prefix argument, providing the location where Boost will place the files it builds. To generate a build configuration that places built files inside a
$ ./bootstrap.sh --prefix=boost_output
- To generate build configuration with Python 2.x support:
./bootstrap.sh --prefix=boost_output --with-python=
- To generate build configuration with Python 3.x support:
./bootstrap.sh --prefix=boost_output --with-python=python3
- To generate build configuration with Unicode support:
./bootstrap.sh --prefix=boost_output --with-icu=
- To perform the actual build, we invoke the
b2 program generated by the above command:
$ ./b2 install
- To build in parallel using all your CPU cores, specify that number:
$ ./b2 install -j 8
- If the build was successful, you will find two subdirectories:
include of include files and
lib of library files in the directory you specified to the
--prefix argument above. These are enough to include in your C++ source files and to link with for compilation.
Tried with: Boost 1.63.0, GCC 4.8.4 and Ubuntu 14.04
Vim can be used to build your code by using the
:make command. It runs the command appropriate for your compiler, parses the compile errors or warnings and provides them in the Quickfix window. The only problem with this is that the build process is synchronous: the build command takes over the terminal and until it is over you can neither view nor interact with Vim.
The Dispatch plugin by Tim Pope enables you to run the build command asynchronously. The plugin can be installed from source here. You have two choices: run the build command asynchronously in the foreground or in the background.
:Make to run the build asynchronously in the foreground. This is possible only if you are using a terminal multiplexer like Tmux. A split terminal opens up at the bottom and you can see the output of your build there. The focus remains in Vim and you can view and interact with the editor while the build carries on. If you are running Vim in a normal terminal, this command just runs the plain old
:Make! to run the build asynchronously in the background. This can be run on Vim running in any setup. The build command runs in the background invisibly and you can view and interact with Vim while this is happening.
:Copen to view the build output either during the build or after it is complete in foreground or background.
I highly recommend this plugin for anyone who is already using
:make since with no change you can now build asynchronously.
Tried with: Vim 7.4 and Ubuntu 14.04
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.
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 libraries of OGRE for recent Visual Studio versions can be downloaded from here.
Tried with: OGRE 1.8.1, Visual Studio 2013 and Windows 7 x64
$ mkdir build
$ cd build
- Configure the features you want OpenCV to be compiled with. I prefer the CMake GUI for this:
$ cmake-gui ..
Click Configure. Go down the list and look for the items named
WITH_*. Each of these is a feature that can be compiled into OpenCV. Choose what you would like and uncheck those not needed.
BUILD_* items: These are related to external libraries. If you enable one of them, during the build, the source code of that external library will be downloaded and built. You typically do not want to do this, since you can install the pre-built library directly by using
apt-get. For example, instead of using
BUILD_JPEG, you can just install the
libjpeg-dev package from Ubuntu repositories.
BUILD_opencv_* items: These are the features of OpenCV. Choose which of these features you need for your work. These features might be interdependent and it is your responsibility to ensure that all the dependent features are also enabled. You can see if the dependencies for the feature you need were met in the output you get after pressing the Configure button.
WITH_* items: These are typically related to external libraries. This is different from
BUILD_* items, since choosing this indicates that you want OpenCV to link with this external library. For example, choosing
WITH_TBB links with the Intel TBB library and certain OpenCV features compute faster due to the added parallelism available from Intel TBB.
After you have chosen the features you need, click Configure again. Examine the output at the bottom and if you are satisfied, click Generate. This generates the Makefile.
Build OpenCV from the Makefile:
The build can take a long time, so you might want to run parallel builds:
$ make -j
- If you find that a feature you want is not being built, then check the output that is at the bottom of the CMake GUI after you press Configure.
Ensure there is nothing displayed in red color. If there is, note down the header file or library that is required and install those packages. Also ensure that all the options you chose have been chosen for build. Some of the features are inter-dependent and may not be built if their dependencies are not chosen.
Another technique is to go to the subdirectory containing the feature and look at the
CMakeLists.txt file there. Look for the text
REQUIRED_DEPS that shows what other OpenCV features need to be present for this feature to be built. Ensure those features are also chosen.
- To install OpenCV that you have built:
$ sudo make install
Tried with: OpenCV 2.4.9 and Ubuntu 14.04
Compiling C++ projects in Visual Studio can take quite a while. A programmer might switch to a different application to do something else (say browse) while the code compiles. It would be nice if the programmer can get a visual notification of the success or failure of the build happening in the background once it is done.
Growl is a neat tool that can make this happen. Here is how to get notifications of your Visual Studio builds using Growl:
- Download and install Growl.
- Download and install the Visual Studio plugin for Growl.
- Open Visual Studio and choose Tools → Growl. (If you do not see a Growl item in the Tools menu, see the end of this post for a fix.)
- In the Growl dialog, enable Notifications and choose whether you want to be notified on Project or Solution builds.
- Run Growl and compile something in Visual Studio. You should see a notification on your display when the build succeeds or fails.
The kind of display used for the notification can be configured in Growl. Enjoy your build notifications! 🙂
I could not get the Visual Studio plugin working on my computer, i.e., there was no Growl menu item in Visual Studio. Though I chose to install for Everyone, I found that the Visual Studio plugin was installing to
C:\Users\Superuser\AppData\Roaming\Microsoft\MSEnvShared\Addins\Growl Add-In, where
Superuser is the login of an administrator. It is actually supposed to install to
C:\Program Files (x86)\Growl Extras\Growl Add-In for Visual Studio\
A quick fix worked for me. I copied the
Growl Add-in folder to
C:\Users\Joe\AppData\Roaming\Microsoft\MSEnvShared\Addins\Growl Add-In, where
Joe is my non-admin username. And when I opened Visual Studio as the user
Joe, Growl worked! 🙂
Tried with: Growl 2.0.8 and Visual Studio 2008 and 2010