Difference between revisions of "Integrating external libraries"

From Wiki for iCub and Friends
Jump to: navigation, search
(OpenCV)
 
(One intermediate revision by one other user not shown)
Line 11: Line 11:
 
   #define YARP_CVTYPES_H_
 
   #define YARP_CVTYPES_H_
  
This will prevent YARP's local copy of the IPL types conflicting with OpenCV.  The two are the same.  An example CMakeLists.txt (from Joerg):
+
This will prevent YARP's local copy of the IPL types conflicting with OpenCV.  The two are the same.  An example CMakeLists.txt (from Joerg, with updates from Eric):
  
 
   PROJECT(kibitzer)
 
   PROJECT(kibitzer)
 
   SET(YARP_DIR "$ENV{YARP_ROOT}" CACHE LOCATION "where is your yarp build directory?")
 
   SET(YARP_DIR "$ENV{YARP_ROOT}" CACHE LOCATION "where is your yarp build directory?")
   FIND_PACKAGE(YARP)
+
   FIND_PACKAGE(YARP REQUIRED)<br>
   SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
+
  # This line will tell CMake to look in the project directory for configure scripts
   FIND_PACKAGE(OpenCV)
+
   SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})<br>
   INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${OPENCV_INCLUDE_DIR_CV})
+
  # Adding 'REQUIRED' will cause CMake to stop with an error if a package is not found
   LINK_LIBRARIES(${OPENCV_LIBRARY})
+
   FIND_PACKAGE(OpenCV REQUIRED)<br>
 +
  # The OPENCV_INCLUDE_DIR_CV variable should be enough to find all needed OpenCV headers
 +
   INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${OPENCV_INCLUDE_DIR_CV})<br>
 +
  # In addition to specifying the libraries to link, the directories containing the
 +
  # libraries should be added in case the libraries are in a non-standard location
 +
  LINK_DIRECTORIES(${OPENCV_LINK_DIRECTORIES})
 +
   LINK_LIBRARIES(${OPENCV_LIBRARIES})<br>
 
   ADD_EXECUTABLE(kibitzer main.cpp)
 
   ADD_EXECUTABLE(kibitzer main.cpp)
 +
 +
----
  
 
=== ImageMagick++ ===
 
=== ImageMagick++ ===
  
 
see example in YARP source code, example/imagemagick
 
see example in YARP source code, example/imagemagick

Latest revision as of 12:16, 24 July 2006

Notes on integrating external libraries in a CMake project.

OpenCV

Eric has commited a "FindOpenCV.cmake" script in:

 iCub/src/vvv/emislive/CMakeModules

If you include opencv and yarp/sig header files in the same file, make sure you put the following line at the top of your program:

 #define YARP_CVTYPES_H_

This will prevent YARP's local copy of the IPL types conflicting with OpenCV. The two are the same. An example CMakeLists.txt (from Joerg, with updates from Eric):

 PROJECT(kibitzer)
 SET(YARP_DIR "$ENV{YARP_ROOT}" CACHE LOCATION "where is your yarp build directory?")
 FIND_PACKAGE(YARP REQUIRED)
# This line will tell CMake to look in the project directory for configure scripts SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR})
# Adding 'REQUIRED' will cause CMake to stop with an error if a package is not found FIND_PACKAGE(OpenCV REQUIRED)
# The OPENCV_INCLUDE_DIR_CV variable should be enough to find all needed OpenCV headers INCLUDE_DIRECTORIES(${CMAKE_SOURCE_DIR} ${OPENCV_INCLUDE_DIR_CV})
# In addition to specifying the libraries to link, the directories containing the # libraries should be added in case the libraries are in a non-standard location LINK_DIRECTORIES(${OPENCV_LINK_DIRECTORIES}) LINK_LIBRARIES(${OPENCV_LIBRARIES})
ADD_EXECUTABLE(kibitzer main.cpp)

ImageMagick++

see example in YARP source code, example/imagemagick