我尝试使用Matlab Engine和C ++,但我遇到了一些问题。 这是我的CMakeList.txt
cmake_minimum_required(VERSION 2.8)
project(test)
SET(PROJECT_PATH "/home/bruno/projects/Test")
SET(CMAKE_CXX_FLAGS "-std=c++0x")
SET(CMAKE_BUILD_TYPE "Debug")
SET(CMAKE_VERBOSE_MAKEFILE ON)
SET(CMAKE_USE_RELATIVE_PATHS ON)
find_package(Eigen3 REQUIRED)
include_directories(
${CMAKE_SOURCE_DIR}
)
include_directories (/home/bruno/MATLAB/R2017a/extern/include/)
link_directories(/home/bruno/MATLAB/R2017a/bin/glnxa64/)
include_directories(${EIGEN3_INCLUDE_DIR})
add_executable(${CMAKE_PROJECT_NAME} test.cpp)
target_link_libraries(${CMAKE_PROJECT_NAME} -pthread )
target_link_libraries( ${CMAKE_PROJECT_NAME} libeng.so )
target_link_libraries( ${CMAKE_PROJECT_NAME} libmx.so )
当我尝试执行test.cpp时,我得到了
/home/bruno/projects/test/test.cpp:44: undefined reference to `matOpen'
和其他未定义的引用。怎么了?
答案 0 :(得分:0)
您没有链接到libmat.so
:
target_link_libraries( ${CMAKE_PROJECT_NAME} libmx libeng libmat )