简体   繁体   中英

Error compiling Aruco on Mac OS X: Undefined symbols for architecture x86_64:

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!)

我的makefile文件的最后一行需要是

target_link_libraries(aruco_simple  aruco ${OpenCV_LIBS})

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM