Reputation: 116
In its new version 2017b, Matlab has released a new MATLAB Engine API for C++: https://fr.mathworks.com/help/matlab/calling-matlab-engine-from-cpp-programs.html
When I try to use this API, (only to start Matlab at the beginning !!), I have an issue using :
std::unique_ptr<MATLABEngine> matlabPtr = startMATLAB();
The compilation is ok, but at the execution :
Here is the call stack:
matlab::engine::initSession --> matlab::engine::startMATLAB --> matlab::engine::startMATLABAsync --> engine_create_session
Now, I use a different way to do my job, but I don't want to let an issue without a solution. Can someone spot the problem with this API?
My configuration :
Upvotes: 2
Views: 1234
Reputation: 1
The solution is very simple. After setting include and library folders, DONOT copy ANY dll files to your own build folder. Then, it will work.
Upvotes: 0
Reputation: 73
Like in the comment, I solved the issue by upgrading Matlab from R2017b to R2018b!
Upvotes: 1
Reputation: 51
Just a few days back, I had the same issue: here
So, I had raised a ticket in MATLAB for technical support. And they suggested to build the project in the following manner which works for me:
Under Linker Input, add the following names to the field marked ADDITIONAL DEPENDENCIES:
libmat.lib
libMatlabEngine.lib
libMatlabDataArray.lib
Make sure that the following directory is in the Windows system
environment PATH:
C:\Program Files\MATLAB\\bin\win64;
C:\Program Files\MATLAB\\extern\bin\win64
Now, build the project and run your application.
Upvotes: 1