I am trying to compile Aruco using their short example. I am using Mac OS X (10.13.2), the compiler is clang (900.0.39.2), opencv (3.4.1_2 installed via brew) and Aruco (3.0.4).
The simple example is:
#include <iostream>
#include <aruco/aruco.h>
#include <opencv2/highgui.hpp>
int main(int argc,char **argv)
{
try
{
if (argc!=2) throw std::runtime_error("Usage: inimage");
aruco::MarkerDetector MDetector;
//read the input image
cv::Mat InImage=cv::imread(argv[1]);
//Ok, let's detect
MDetector.setDictionary("ARUCO_MIP_36h12");
//detect markers and for each one, draw info and its boundaries in the image
for(auto m:MDetector.detect(InImage)){
std::cout<<m<<std::endl;
m.draw(InImage);
}
cv::imshow("in",InImage);
cv::waitKey(0);//wait for key to be pressed
} catch (std::exception &ex)
{
std::cout<<"Exception :"<<ex.what()<<std::endl;
}
}
My CMakeLists.txt
is:
cmake_minimum_required(VERSION 2.8)
project(aruco_testproject)
SET(CMAKE_CXX_FLAGS "-std=c++11")
find_package(aruco REQUIRED )
add_executable(aruco_simple aruco_simple.cpp)
target_link_libraries(aruco_simple aruco)
And the error I get when running make
(after running cmake
with no issues) is:
Scanning dependencies of target aruco_simple
[ 50%] Building CXX object CMakeFiles/aruco_simple.dir/aruco_simple.cpp.o
[100%] Linking CXX executable aruco_simple
Undefined symbols for architecture x86_64:
"cv::imread(cv::String const&, int)", referenced from:
_main in aruco_simple.cpp.o
"cv::imshow(cv::String const&, cv::_InputArray const&)", referenced from:
_main in aruco_simple.cpp.o
"cv::waitKey(int)", referenced from:
_main in aruco_simple.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [aruco_simple] Error 1
make[1]: *** [CMakeFiles/aruco_simple.dir/all] Error 2
make: *** [all] Error 2
I am fairly new to compiling (as maybe obvious!)