Skip to content

Download and install

Opzet edited this page Feb 4, 2016 · 17 revisions

Home > [Download and install](Download and install) [(Italiano)](Scaricare ed installare la libreria)

Prerequisites

To compile and install Rpi-hw library on your Raspberry Pi you need some dependencies:

  • g++ (4.7 or higher, or your favorite C++11 compiler)
  • cmake (2.6 or higher)
  • FreeType - to support standard fonts (optional)
  • GraphicsMagick++ - to handle several image formats (optional)
  • doxygen (only if you want to build the documentation locally)

On Raspbian (or Debian), you can use apt to install these at once:

$ sudo apt-get install g++-4.7 cmake libfreetype6-dev libgraphicsmagick++1-dev doxygen

Then, set the default g++ version:

$ sudo ln -fs /usr/bin/g++-4.7 /usr/bin/g++

Get the latest release

To get the latest source of Rpi-hw library, you can easily clone its git repository by running:

$ git clone https://github.com/Wicker25/Rpi-hw

Otherwise, you can download it as a compressed archive and extract it with the following commands:

$ wget https://github.com/Wicker25/Rpi-hw/archive/master.tar.gz -O rpi-hw.tar.gz
$ tar -zxvf rpi-hw.tar.gz

Building with CMake

Once you have the source code and its dependencies, you can proceed to building it. First, move into the source directory:

$ cd Rpi-hw*

Then, lunch cmake to generate the makefiles:

$ cmake . -DCMAKE_INSTALL_PREFIX=/usr

If Raspberry Pi revision number was not automatically recognized, you can manually specify it adding the directive RPI_REVISION to CMake arguments. For example:

$ cmake . -DCMAKE_INSTALL_PREFIX=/usr -DRPI_REVISION=0x1234

Similarly, you can compile the library without FreeType or GraphicsImage++ support, through the directives DUSE_FREETYPE=OFF and DUSE_MAGICK=ON. For example:

$ cmake . -DCMAKE_INSTALL_PREFIX=/usr -DUSE_FREETYPE=OFF -DUSE_MAGICK=ON 

if you get error could NOT find FREETYPE_INCLUDE_DIRS with -DUSE_FREETYPE=ON

The problem is cmake is < 3.0.1, 
/usr/share/cmake-2.8/Modules/FindFreetype.cmake does not support latest freetype 6 paths. 

To check you cmake version use, 
$ cmake /V 

cmake version 2.8.9 

To upgrade  
sudo apt-get update
apt-get install cmake

Problem is @ 4 Feb 16 version 2.8.9 is highest

To fix manually extract and overwrite /usr/share/cmake-2.8/Modules/FindFreetype.cmake from 
https://cmake.org/files/v3.5/cmake-3.5.0-rc1.tar.gz archive

Finally, compile the entire library by running:

$ make

You can also build a copy of the documentation through doxygen using the command:

$ make doc

Installing the library

Now you can install the library on your system by running:

$ sudo make install

If you're using a Debian-based system, including Raspbian, you should think about using checkinstall instead of make install to build and install a new Debian package of the library.

Building the examples

The source of Rpi-hw includes some examples that show how the library works. You can build all examples at once using the following commands:

$ cd examples
$ cmake .
$ make