Webots User Guide - chapter 4 - section 3

Webots User Guide


4.3 Using C

4.3.1 Introduction

The C API (Application Programming Interface) is composed of a set of about 200 C functions that can be used in C or C++ controller code. This is the low level interface with the Webots simulator; all other APIs are built over the C API. A majority of Webots controller examples are written in C, therefore the C API is Webots de facto standard API. Although less represented in the controller examples, the other APIs offer exactly the same functionality as the C API.

4.3.2 C/C++ Compiler Installation

Windows Instructions

The Windows version of Webots comes with a pre-installed copy of the MinGW C/C++ compiler, so there is usually no need to install a separate compiler. The MinGW compiler is a port of the GNU Compiler Collection (gcc) on the Windows platform. The advantage of using the MinGW compiler will be the better portability of your controller code. If you develop your code with MinGW it will be straightforward to recompile it on the other Webots supported platforms: Mac OS X and Linux. However, if you prefer using the Visual C++ compiler you will find instructions there.

Mac OS X Instructions

In order to compile C/C++ controllers on the Mac, you will need to install Apple Xcode. Xcode is a suite of tools, developed by Apple, for developing software for Mac OS X. Xcode is free and is usually included with every copy of the Mac OS X installation DVD. Otherwise Xcode can also be downloaded from the Apple Developer Connection website. Webots will need principally the gcc (GNU C Compiler) and make commands of Xcode. In the Xcode installer it is important to check the "UNIX Development Support" checkbox: otherwise the necessary commands won't be installed in /usr/bin and so Webots may be unable to find them.

Linux Instructions

For compiling C controllers, Webots will need the GNU C Compiler and GNU Make utility. On Linux, these tools are often pre-installed, otherwise you will need to install them separately (gcc and make packages). For C++ you will also need the GNU C++ Compiler (g++ package). Optionally you can also install the GNU Debugger (gdb package).

release 7.0.2
Copyright © 2012 Cyberbotics Ltd. All right reserved.