在本地安装aruco lib 2.019

时间:2018-05-28 12:09:06

标签: c++ opencv ros aruco

在Ubuntu 14.04中安装aruco lib时遇到一些麻烦,我没有任何sudo权限,也没有访问/ usr /...

我下载了.zip aruco lib并执行了以下操作:

mkdir build
cd build
cmake .. (gives me: -- Build files have been written to: software/aruco-2.0.19/build
make  (gives me some warning msg but nothing critical)
make install (gives an error)

make install给了我:

-- Install configuration: "Debug"
CMake Error at cmake_install.cmake:36 (FILE):
  file cannot create directory: /usr/local/lib/cmake.  Maybe need
  administrative privileges.

现在简单的问题:

如何在build文件夹的Makefile文件中设置本地安装lib的路径

好吧,我想将这个库与ros一起使用,我将它包含在CMakeLists.txt中的cpp包中:

cmake_minimum_required(VERSION 2.8.3)
PROJECT(ros_aruco)

## 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 roscpp tf std_msgs sensor_msgs geometry_msgs message_generation genmsg cv_bridge image_transport)

#INCLUDE_DIRECTORIES("/hri/localdisk/markus/software/aruco-2.0.19/src")
SET(ARUCO_INCLUDE_DIRS "/hri/localdisk/markus/software/aruco-2.0.19/src") ## headers!
SET(CMAKE_MODULE_PATH "/hri/localdisk/markus/software/aruco-2.0.19/build") ## path to Findaruco.cmake

#SET(CMAKE_MODULE_PATH ${ARUCO_PATH}/lib/cmake)
#SET(ARUCO_INCLUDE_DIRS ${ARUCO_PATH}/include/aruco)

## System dependencies are found with CMake's conventions
FIND_PACKAGE(aruco REQUIRED)
FIND_PACKAGE(OpenCV REQUIRED)

INCLUDE(FindPkgConfig)

SET(ROS_BUILD_TYPE Release)
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=gnu++11 -march=core-avx-i -O2")

## Specify additional locations of header files
## Your package locations should be listed before other locations
include_directories(
    ${catkin_INCLUDE_DIRS}
    ${ARUCO_INCLUDE_DIRS}
)

add_executable(ros_aruco
    src/ros_aruco.cpp 
)

add_dependencies(ros_aruco ${catkin_EXPORTED_TARGETS})

# give .so librarys:
target_link_libraries(ros_aruco 
    ${catkin_LIBRARIES}
    ${OpenCV_LIBS}
        "/hri/localdisk/markus/software/aruco-2.0.19/build/src"
)

在使用该代码进行编译时,我得到了这个我真正想要解决的错误:

CMakeFiles/ros_aruco.dir/src/ros_aruco.cpp.o: In function `main':
ros_aruco.cpp:(.text.startup+0x18d): undefined reference to `aruco::CameraParameters::readFromXMLFile(std::string)'
ros_aruco.cpp:(.text.startup+0x1cf): undefined reference to `aruco::CameraParameters::resize(cv::Size_<int>)'
ros_aruco.cpp:(.text.startup+0x49a): undefined reference to `aruco::CameraParameters::CameraParameters(aruco::CameraParameters const&)'
ros_aruco.cpp:(.text.startup+0x4bd): undefined reference to `aruco::MarkerDetector::detect(cv::Mat const&, std::vector<aruco::Marker, std::allocator<aruco::Marker> >&, aruco::CameraParameters, float, bool)'
ros_aruco.cpp:(.text.startup+0xfce): undefined reference to `aruco::CvDrawingUtils::draw3dCube(cv::Mat&, aruco::Marker&, aruco::CameraParameters const&, bool)'
ros_aruco.cpp:(.text.startup+0xfe7): undefined reference to `aruco::CvDrawingUtils::draw3dAxis(cv::Mat&, aruco::Marker&, aruco::CameraParameters const&)'
CMakeFiles/ros_aruco.dir/src/ros_aruco.cpp.o: In function `_GLOBAL__sub_I_current_image_copy':
ros_aruco.cpp:(.text.startup+0x1fa0): undefined reference to `aruco::CameraParameters::CameraParameters()'
ros_aruco.cpp:(.text.startup+0x1fbe): undefined reference to `aruco::MarkerDetector::MarkerDetector()'
ros_aruco.cpp:(.text.startup+0x1fcd): undefined reference to `aruco::MarkerDetector::~MarkerDetector()'

2 个答案:

答案 0 :(得分:0)

编译时遇到的问题是你无法找到aruco库的共享对象(.so

target_link_libraries中你需要为你的* .so添加路径由aruco构建 我想你还需要删除FIND_PACKAGE(aruco REQUIRED)

EDIT1

发现这个Link

答案 1 :(得分:0)

因此,首先,您没有sudo权限,也无法将库安装到系统默认的/usr/local/libusr/lib等。这意味着赢得了find_package()不会给您反馈。您可以做的就是像add_library()一样自己构建所有aruco库,并编写自己的link_directories() include_directories() link_library()等。

但是,您也可以修改安装目标。