Could not find matlabEngine using the following names: libMatlabEngine
Mostrar comentarios más antiguos
Hi,
I am currently trying to run some MATLAB code in a c++ project. Obviously, to make things more complicated I am also new to both c++ and cmake.
So here is my top-Level CMakelists.txt:
cmake_minimum_required(VERSION 3.19)
project(matlabapi)
set(CMAKE_CXX_STANDARD 14)
# sets the matlab root directory
set(Matlab_ROOT_DIR /usr/local/MATLAB/R2021a)
# included directories
include_directories(${Matlab_ROOT_DIR}/extern/bin/glnxa64/)
# print all included directories
get_property(dirs DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY INCLUDE_DIRECTORIES)
foreach(dir ${dirs})
message(STATUS "Included Directory is: '${dir}'")
endforeach()
# Libraries
find_library(matlabEngine libMatlabEngine REQUIRED)
# Executable
add_executable(matlabapi main.cpp)
# Linker stuff
target_link_libraries(matlabapi matlabEngine)
and the main.cpp which is the executable:
#include <iostream>
#include "MatlabEngine.hpp"
#include "MatlabDataArray.hpp"
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
From my understanding, Cmake should find the library here:
/usr/local/MATLAB/R2021a/extern/bin/glnxa64/
which includes two files:
libMatlabDataArray.so libMatlabEngine.so
What am I missing? Cmake throws the error in cmake configuration time:
CMake Error at CMakeLists.txt:17 (find_library):
Could not find matlabEngine using the following names: libMatlabEngine
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Call MATLAB from C++ en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!