Integrate Your Own Code with OMPL’s Build System {#buildSystem}
When developing your own code that relies on OMPL, you have several options:
Install OMPL and use your own build system: First, if you are installing OMPL “by hand” (i.e., not through your package manager), run the following commands in your OMPL build directory:
cmake -DCMAKE_INSTALL_PREFIX=/some/path make install
See Build Options for details on how to enable/disable different OMPL-specific features. Below are the specifics for different build systems:
CMake: For ease of use with CMake, we have included a CMake module for finding in `CONFIG`` mode. If you use CMake in your own project, you can simply use the following commands in your CMakeLists.txt to find and link to the OMPL target.
find_package(ompl CONFIG) target_link_libraries(your_library PUBLIC ompl::ompl)
To support the previous CMake module behavior, the following variables are defined. These are for backwards compatability, but not recommended anymore.
- `OMPL_FOUND` - `TRUE` - `OMPL_INCLUDE_DIRS` - The OMPL include directory - `OMPL_LIBRARIES` - The OMPL library - `OMPLAPP_LIBRARIES` - The OMPL.app libraries (if installed) - `OMPL_VERSION` - The OMPL version in the form <major>.<minor>.<patchlevel> - `OMPL_MAJOR_VERSION` - Major version - `OMPL_MINOR_VERSION` - Minor version - `OMPL_PATCH_VERSION` - Patch version
Makefiles: If you use Makefiles, add “
-I/usr/local/include
” (or, e.g., “-I${HOME}/ompl/src
”) to your compile flags, and “-L/usr/local/lib -lompl
” (or, e.g., “-L${HOME}/ompl/build/Release/lib -lompl
”) to your link flags. The compile and link flags can also be obtained using “pkg-config --cflags ompl
” and “pkg-config --libs ompl
”, respectively.Autotools: Use the pkg-config autoconf macro PKG_CHECK_MODULES([OMPL],[ompl >= 0.10]). This is will define
OMPL_LIBS
andOMPL_CFLAGS
if OMPL was found.Eclipse CDT: Below is a brief set of instructions for getting OMPL to work with Eclipse CDT. These instructions have been verified to work with Eclipse Indigo with CDT.
Click File -> New -> New Project.
Choose C++ Project; click Next.
Give your project a name; choose Executable -> Empty Project for type; click Next.
Click Advanced Settings to open the Properties window for your project.
Go to C/C++ Build -> Settings in the left pane.
Under the Tool Settings tab, choose Cross G++ Compiler -> Includes. To the “Include paths” section, add the location of the OMPL source tree. For example, on a Linux system with default installation path, you should use “/usr/local/include”. Click Apply.
Again under the Tool Settings tab, choose Cross G++ Linker -> Libraries. To the “Libraries” section, add “ompl” (and, if needed, any Boost libraries, “ompl_app_base” and “ompl_app”) . To the “Library search path” section, add the location of the OMPL library files. For example, on a Linux system with default installation path, you should use “/usr/local/lib”. Click Apply.
Click OK to leave the Properties window. Click Finish.
IDE’s such as MS Visual Studio and Xcode: consult your IDE’s manual.
Add your own code in OMPL’s directory structure: This option is recommend if you extend functionality of OMPL that you wish to contribute back to the OMPL project (see Third-Party Contributions for details). OMPL uses CMake for its build system. CMake can generate Makefiles and project files for many IDE’s. If you create C++ code under ompl/src/ompl/[folder], you need to re-run CMake. CMake will detect your code if [folder] is one of the directories already included by OMPL. If you want your code to be in a different location, you should update ompl/src/ompl/CMakeLists.txt accordingly. See the Python documentation for specific instructions on how to create python bindings for your own code.