This website uses browsing/session and functional cookies to ensure you get the best experience. Learn More

CompileMacOSX

From Wiki for iCub and Friends
Jump to: navigation, search

Important: we assume here that you have completed the previous steps in the manual (see Section 6.1 "Prepare Your System" in the manual's main page).
Also note that Mac OS X is officially not supported and everything said here should be taken as experimental, which makes the building procedure slightly more time-consuming than under Linux or Windows but I hope that these hints will help.


Before you compile the code you need to generate make files.

Here we assume you have completed the previous steps (preparing your system, getting the software, setting up your environment).

Contents

Compiling YARP

Create the YARP Makefiles

Run (don't forget to set the environment variables first):

 cd $YARP_ROOT
 ccmake ./

Choose the following options:

  • CMAKE_BUILD_TYPE, set to "Release" in case you'd like to optimize
  • CREATE_LIB_MATH, set to ON

In order to activate yarpview edit first $YARP_ROOT/conf/FindGtkPlus.cmake like described in Yarp on Mac and set

  • CREATE_GUIS to ON

Important: CREATE_GUIS and CREATE_LIB_MATH require you have installed the libraries gtk and gsl (see PrepareMacOSX)

Create the makefiles by selecting configure several times and then generate.

Installation: CMake automatically creates an install rule for target/project. In the documentation we assume you install binaries in $YARP_ROOT/bin and $YARP_ROOT/lib. The compiler will build executables and libraries there, so you don't need to perform the installation. You can instruct CMake so that it generates make/project files that install to other places, for example $YARP_DIR/bin and $YARP_DIR/lib. You can do this by running cmake again and setting the variable:

  • CMAKE_INSTALL_PREFIX to $YARP_DIR

When you do make install all binaries will be copied to $YARP_DIR/bin and $YARP_DIR/lib.

Of course you can customize the installation directory as you wish, however the remainder of the documentation assumes the above configuration.

  • Depending on the hardware on your system you might want to compile additional device drivers. This is done for example on the pc104. Instruction for doing this are reported elsewhere.

Compile

Now we are ready to compile. This is easy.

Run:

 cd $YARP_ROOT
 make

Example -- is YARP available?

Now we're ready to run a simple Yarp code to test the installation so far. You might want to prepare a yarp.conf file in the conf directory similar to this one:

127.0.0.1 10000

which tells Yarp (the server) to start on the localhost and respond to port 10000. This allows Yarp applications to find the name server (see next chapter).

You can then try running the server. On a terminal window, type:

yarpserver &

and you should see:

yarp: Port /root active at tcp://127.0.0.1:10000 Name server can be browsed at http://127.0.0.1:10000/ yarp: Bootstrap server listening at mcast://224.2.1.1:10001

if you type on a web browser http://127.0.0.1:10000 you get information about the name server (registered ports, info, etc.).

For the time being we can just check functionality by running a simple example. On another terminal type:

yarp read /portread

on a third terminal:

yarp write /portwrite

and on yet another terminal:

yarp connect /portwrite /portread

you'll see the effect on the name server:

yarp: registration name /portwrite ip 127.0.0.1 port 10012 type tcp
yarp: registration name /portread ip 127.0.0.1 port 10002 type tcp

Now, anything typed on the yarp write will be sent and printed on the read side.

Compile the iCub software

Manual adjustments specific to Mac OS X

So far everything was pretty straight forward on the Mac. Now comes a bit of manual editing that is due to the fact that the icub software was not written for Mac OS X.

1. If you modified FindGtkPlus.cmake previously, undo your changes now
In order to make compile yarpview you had to outcomment a section in $YARP_ROOT/conf/FindGtkPlus.cmake like described in YARP on Mac. This very change will make the canloader module crash if you try to compile the icub repository as it is. So if you did outcomment the said section before in order to compile yarpview, do the opposite now and comment it again. This is a hack and not even an elegant one. So any suggestions how to circumvent this uncomment-comment are highly appreciated.

2. Prerequisites for getting the simulator to compile (thanks to Gianluca for pointing this out)
In order to compile the simulator (which will be compiled by default) you need to perform the following changes in $ICUB_ROOT/src/iCubSimulation/CMakeLists.txt:
Add below the line LINK_LIBRARIES(${ODE_LIBRARIES})

 IF (APPLE)
   INCLUDE_DIRECTORIES(${OPENGL_INCLUDE_DIR})
   LINK_LIBRARIES(${OPENGL_LIBRARIES})
   ADD_DEFINITIONS(-DHAVE_APPLE_OPENGL_FRAMEWORK)
 ENDIF(APPLE)

Add below the line ADD_DEFINITIONS(-DEXPERIMENTAL_CONFIG_METHOD)

 IF(APPLE)
   ADD_EXECUTABLE(${PROJECTNAME} ${folder_source} ${folder_header}
   /Library/Frameworks/SDL.framework/Resources/SDLMain.m)
 ELSE(APPLE)
   # original line without Apple-specific change
   ADD_EXECUTABLE(${PROJECTNAME} ${folder_source} ${folder_header})
 ENDIF(APPLE)


3. If you want to enable CREATE_GUIS_QT (see also below), you have also to adjust the CMakeLists.txt files in the root directories of the following modules
(the root directory with regard to the libYARP_QWidgets module for example is $ICUB_ROOT/src/gui/libYARP_QWidgets):

  • libYARP_QWidgets
  • libICUB_QWidgets
  • qViewerGui
  • applicationGui
  • iCubGui

in the following way:
Add in the corresponding CMakeLists.txt files of the mentioned modules below the lines INCLUDE_DIRECTORIES an additional one, for example like:

 IF (APPLE)
    INCLUDE_DIRECTORIES(
    /usr/X11R6/include
    )
 ENDIF (APPLE)

This is the directory where your GL/qt.h and GL/glu.h reside. (The author is not sure anymore if he did anything particular in order to have these files in this particular directory, they might come with the X11 installation which is a default with Mac OS X 10.5 and later versions but an optional install with Mac OS X 10.4).
Mac OS X comes with its own version of OpenGL and one typically seems to include OPENGL/qt.h instead of GL/qt.h which is the cause for the compiler errors. The headers of the Mac version of OpenGL reside typically in /System/Library/Frameworks/OpenGL.framework/Headers were they are found automatically by cmake. So an alternative to the changes above would be for Mac users to change the headers of the mentioned modules to include OPENGL/qt.h and OPENGL/qlu.h instead of their GL/.. counterparts.

A more elegant way to fix this would be to either use a cmake variable instead of an absolute path for example by defining a FindOPENGL.cmake or to introduce a OS switch in the preprocessor directives of the header files of the corresponding modules. Feel free to contribute.


Generate makefiles

Now you can generate make files (Technically speaking you could have generated them before already but the compilation based on those would have failed). In $ICUB_ROOT:

ccmake ./

You don't need particular options. If you want to compile using optimization just set:

  • CMAKE_BUILD_TYPE to "Release"

Other options are:

  • CREATE_GUIS_GTK
  • CREATE_GUIS_GTKMM
  • CREATE_GUIS_QT

These options are recommended, because they enable compilation of some useful GUIs. Important: these options can be enabled only if you have installed the required libraries: gtk, gtkmm and qt (see PrepareMacOSX).

  • Similarly to YARP, by default make will build executables and libraries in $ICUB_ROOT/bin and $ICUB_ROOT/lib. You can customize where "make install" will copy these files by setting: CMAKE_INSTALL_PREFIX to something you like.

If you need to compile devices that provide interface to the hardware you can follow this link Compilation on the pc104

Compile

Compile the code.

 cd $ICUB_ROOT
 make
Personal tools
Namespaces

Variants
Actions
Navigation
Print/export
Toolbox