1. 编辑mrpt的CMakeList.txt文件,查找需要的mrpt_package和添加依赖
#-----------------------------------------------------------------------------------------------
# CMake file for the MRPT example: rbpf-slam
#
# Run with "ccmake ." at the root directory, or use it as a template for
# starting your own programs
#-----------------------------------------------------------------------------------------------
SET(sampleName rbpf-slam)
SET(PRJ_NAME "EXAMPLE_${sampleName}")
# ---------------------------------------
# Declare a new CMake Project:
# ---------------------------------------
PROJECT(${PRJ_NAME})
# These commands are needed by modern versions of CMake:
CMAKE_MINIMUM_REQUIRED(VERSION 2.4)
if(COMMAND cmake_policy)
cmake_policy(SET CMP0003 NEW) # Required by CMake 2.7+
if(POLICY CMP0043)
cmake_policy(SET CMP0043 OLD) # Ignore COMPILE_DEFINITIONS_<Config> properties.
endif()
endif(COMMAND cmake_policy)
# ---------------------------------------------------------------------------
# Set the output directory of each example to its corresponding subdirectory
# in the binary tree:
# ---------------------------------------------------------------------------
SET(EXECUTABLE_OUTPUT_PATH ".")
# --------------------------------------------------------------------------
# The list of "libs" which can be included can be found in:
# http://www.mrpt.org/Libraries
#
# The dependencies of a library are automatically added, so you only
# need to specify the top-most libraries your code depend on.
# --------------------------------------------------------------------------
FIND_PACKAGE(MRPT REQUIRED slam;gui;obs;hwdrivers) #在这里添加mrpt package
# ---------------------------------------------
# TARGET:
# ---------------------------------------------
# Define the executable target:
ADD_EXECUTABLE(${sampleName} rbpf-slam.cpp
${MRPT_VERSION_RC_FILE})
SET_TARGET_PROPERTIES(
${sampleName}
PROPERTIES
PROJECT_LABEL "(EXAMPLE) ${sampleName}")
# Add special defines needed by this example, if any:
SET(MY_DEFS )
IF(MY_DEFS) # If not empty
ADD_DEFINITIONS("-D${MY_DEFS}")
ENDIF(MY_DEFS)
# Add the required libraries for linking:
TARGET_LINK_LIBRARIES(${sampleName}
${MRPT_LINKER_LIBS} # This is filled by FIND_PACKAGE(MRPT ...)
"" # Optional extra libs...
)
# Set optimized building:
IF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3")
ENDIF(CMAKE_COMPILER_IS_GNUCXX AND NOT CMAKE_BUILD_TYPE MATCHES "Debug")
# -------------------------------------------------------------------------
# This part can be removed if you are compiling this program outside of
# the MRPT tree:
# -------------------------------------------------------------------------
IF(${CMAKE_PROJECT_NAME} STREQUAL "MRPT") # Fails if build outside of MRPT project.
DeclareAppDependencies(${sampleName} mrpt-slam;mrpt-gui;mrpt-obs;mrpt-hwdrivers) # Dependencies 这里添加依赖
ENDIF(${CMAKE_PROJECT_NAME} STREQUAL "MRPT")
# -------------------------------------------------------------------------
2. 使用cmake-gui,编译器选择vc2013 64bit,生成项目,用vs2013打开,配置管理器为x64。
3. 项目属性中,vc++目录(若有其他需求,还需要添加其他目录)
添加包含目录 C:\Program Files\MobileRobots\Aria\ArNetworking\include;C:\Program Files\MobileRobots\Aria\include;
添加库目录 C:\Program Files\MobileRobots\Aria\lib64;
链接器-输入-附加依赖项
添加 AriaDebugVC12.lib;ArNetworkingDebugVC12.lib;
4. 将C:\Program Files\MobileRobots\Aria\bin64下的AriaDebugVC12.dll和ArNetworkingDebugVC12.dll拷贝到项目目录下,再拷贝到x64\debug目录下。
5. F7,即可生成通过。