0

I have this error trying to compile a package. This is the CMAKE where i have the error:

    cmake_minimum_required(VERSION 2.8.3)
project(aruco_marker_detector)

## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
  cv_bridge
  geometry_msgs
  image_transport
  roscpp
  std_msgs
  tf
  tf_conversions
  uvc_camera
)

## System dependencies are found with CMake's conventions
# find_package(Boost REQUIRED COMPONENTS system)

##############################################################################
# OpenCV
##############################################################################
find_package(OpenCV REQUIRED)

##############################################################################
# Eigen
##############################################################################
find_package(Eigen REQUIRED)
add_definitions(${EIGEN_DEFINITIONS})

##############################################################################
# AruCo
##############################################################################
find_package(aruco REQUIRED )

The error is about Aruco,the system cannot find the libraries!!

I don't really now how to fix it. I have installed aruco 1.2.4 following the instructions in this site "http://maztories.blogspot.com.es/2013/07/installing-aruco-augmented-reality.html".

  • Did you see [that question](http://stackoverflow.com/q/33251390/3440745)? Its author says that it works after setting variable `CMAKE_MODULE_PATH`. – Tsyvarev Oct 23 '15 at 07:18
  • i saw it right now,so do you suggest to add in the CMAKE this line set(CMAKE_MODULE_PATH /usr/local/lib/cmake) Or the answer,like set the CMAKE variable called CMAKE_PREFIX_PATH using this: cmake -D CMAKE_PREFIX_PATH=/usr/local/lib ???? – Marcello Chiurazzi Oct 23 '15 at 07:31
  • As usual: If you expect to build project only on single PC, you may setup all variables in `CMakeLists.txt` file. If you want to build your project on several machines, it is better to not change `CMakeLists.txt` but pass variable definitions to `cmake` call. – Tsyvarev Oct 23 '15 at 07:57
  • the second way is for sure the best but how i can pass variable definitions to cmake call? Sorry for the questions i'm using ubuntu from few months and i have problems with this kind of staff. In my specific case if i want to use the most genral solution what i should do? – Marcello Chiurazzi Oct 23 '15 at 08:05
  • I mean `cmake -DCMAKE_PREFIX_PATH=/usr/local/lib `. It actually passes `CMAKE_PREFIX_PATH` variable definition to cmake. – Tsyvarev Oct 23 '15 at 08:09
  • Your original question was about finding `aruco` library by `find_package()` call. New question is about `add_executable()` call, which is unrelated to previous `find_package()` one. *Question editing* is not intended for such modifications. Instead, you may create **new question**, which describes your **new problem**. In the new question you may add link to this one, if you think that this will help in understanding of the question . – Tsyvarev Oct 23 '15 at 09:17
  • ok sorry i will do it immediately,i hope you will answer to that one too helping me to figure it out :D – Marcello Chiurazzi Oct 23 '15 at 09:31
  • Are you using Windows or Linux? – Tony Luo Apr 07 '16 at 10:24

2 Answers2

1

If you've configured OpenCV correctly, you can just generate ArUco's lib yourself:

# latest aruco version available at: http://sourceforge.net/projects/aruco/files/
# also, aruco is now part of OpenCV: http://docs.opencv.org/master/d9/d6d/tutorial_table_of_content_aruco.html
# here I'm demonstrating the usage of v1.2.5

# useful definitions
set(ARUCO_DIR     "/PATH/TO/aruco-1.2.5")
set(ARUCO_INCLUDE "${ARUCO_DIR}/include")
set(ARUCO_SRC     "${ARUCO_DIR}/src")
set(ARUCO_LIB      aruco-1.2.5)

# find the source files
file(GLOB hdrs "${ARUCO_INCLUDE}/aruco/*.h*")
file(GLOB srcs "${ARUCO_SRC}/*.c*")

# create aruco's cmake target
add_library(${ARUCO_LIB} STATIC "${hdrs}" "${srcs}")

# link aruco against OpenCV
find_package(OpenCV REQUIRED)
include_directories(SYSTEM "${OpenCV_INCLUDE_DIRS}" ${OpenCV_LIBS})


# use aruco in your project
# useful project definitions
set(MY_SOURCES    "list your sources here")
set(MY_EXECUTABLE super_ar_program)

# create the executable's cmake target
add_executable(${MY_EXECUTABLE} "${MY_SOURCES}")

# the executable against aruco
include_directories(SYSTEM "${ARUCO_INCLUDE}" "${OpenCV_INCLUDE_DIRS}")
target_link_libraries(${MY_EXECUTABLE} ${ARUCO_LIB} ${OpenCV_LIBS})

EDIT: I've changed the script to use include_directories() instead of target_include_directories().

maddouri
  • 3,737
  • 5
  • 29
  • 51
  • how i should do it,i mean..i have to substitute in my CMAKE the line find aruco with this lines? – Marcello Chiurazzi Oct 23 '15 at 07:33
  • I changed the line find_package(aruco REQUIRED) with your code and i have a problem at the end on the line: target_include_directories The error is this: Unknown CMake command "target_include_directories". -- Configuring incomplete, errors occurred! – Marcello Chiurazzi Oct 23 '15 at 07:50
  • @MarcelloChiurazzi: CMake command "target_include_directories" has been included into CMake after 2.8.3 version which you use. Alternative is to `include_directories(${OpenCV_LIBS})` *before* `add_library()` call. – Tsyvarev Oct 23 '15 at 08:02
  • @MarcelloChiurazzi Check out the edited version. As you said, just replace `find_package(aruco REQUIRED)` with the provided commands. (of course, you'll have to adapt the paths/names to suit your config/needs) – maddouri Oct 23 '15 at 08:38
  • Guys other error :( This is the line: # create the executable's cmake target add_executable(${MY_EXECUTABLE} "${MY_SOURCES}") ERROR:aruco_marker_detector_2/CMakeLists.txt:60 (add_executable): Cannot find source file: list your sources here Tried extensions .c .C .c++ .cc .cpp .cxx .m .M .mm .h .hh .h++ .hm .hpp .hxx .in .txx I REDITED THE QUESTION – Marcello Chiurazzi Oct 23 '15 at 08:52
  • You are aware that you have to put the list of source files in `MY_SOURCES`, right ? Please post the whole script in order for us to give you relevant recommendations on how to solve the problem. – maddouri Oct 23 '15 at 09:52
  • @MarcelloChiurazzi I had a look at what you _removed_ from your _edited_ question. Here's the problem: you've just copy/pasted the line `set(MY_SOURCES "list your sources here")` without actually listing your executable's source files. – maddouri Oct 23 '15 at 09:55
0

Here is My simplyfied cmake file with aruco 3.09. Should also work for other versions of 3.0+, just change the directory name.

cmake_minimum_required( VERSION 2.8 )

## Required software
#find_package( <<<name>>> REQUIRED )

## Sources and headers
include_directories( ${CMAKE_CURRENT_SOURCE_DIR} )
include_directories("/home/corvus/opencv/include/opencv2/")
include_directories("/home/corvus/aruco-3.0.9/aruco-3.0.9/aruco_src/include/")
link_directories( /home/corvus/aruco-3.0.9/aruco-3.0.9/aruco_src/lib/ )

## Find all source and header files to be compiled into object files
file( GLOB SOURCES *.cc *.cpp *.hpp *.hh )

## Find all aruco source and header files to be compiled into object files
## file(GLOB ARUCO_HEADERS "${ARUCO_INCLUDE}/aruco/*.h*")
## file(GLOB ARUCO_SOURCES "${ARUCO_SRC}/*.c*")

## Add OpenCV Library
add_library(OpenCV SHARED IMPORTED)
set_property(TARGET OpenCV PROPERTY IMPORTED_LOCATION "/usr/local/lib")
find_package( OpenCV REQUIRED )

## Add Eigen3
find_package(Eigen3 REQUIRED)

## C++ compiler options
set( CMAKE_CXX_FLAGS "-Wall -Wextra -std=c++11 -pthread -I/usr/include/eigen3/ -L/usr/local/libs \ -lopencv_objdetect \ " )
    ## to disable all warnings 
    ## set( CMAKE_CXX_FLAGS "" ) 
set( CMAKE_CXX_FLAGS_DEBUG "-g -O0" )
set( CMAKE_CXX_FLAGS_RELEASE "-O3" )
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_CXX_STANDARD_REQUIRED ON) #...is required...
set(CMAKE_CXX_EXTENSIONS ON) #...with compiler extensions like gnu++11

## Source file containing the "main" function
set( MAIN_SOURCES main.cpp )
## Specify a name for the generated executable file
set( MAIN_EXE_NAME MarkerDetection )


## 1. Compile...
add_executable( ${MAIN_EXE_NAME} ${MAIN_SOURCES}
                                 ${SOURCES}
              )


## 2. Link...
target_link_libraries( ${MAIN_EXE_NAME} )
target_link_libraries(${MAIN_EXE_NAME} ${OpenCV_LIBS})
target_link_libraries(${MAIN_EXE_NAME} aruco)


## 3. Install...
install( TARGETS ${MAIN_EXE_NAME}
         RUNTIME DESTINATION bin )