It has been a long time, but I ran into the same problem and found interesting information about it.
First of all, in the new version of MATLAB (2016a), the search path is MATLAB Engine C: \ Program Files \ MATLAB \ R2016a (or the same path on which you install MATLAB). Therefore, if you do not change it, C ++ can use all the built-in functions. In addition, you can use the functions from Toolboxes!
But there is another problem: what about custom functions? Therefore, I need to place the .m file directly in C: \ Program Files \ MATLAB \ R2016a to make it visible to the MATLAB Engine.
Here we can go the other way - just add the path to your .m file in MATLAB via C ++:
char CommandChangePath[MAX_PATH]; strcpy(CommandChangePath, "addpath('C:\\Users\\SuperUser\\Documents\\Visual Studio 2017\\Projects\\MyCppProject')"); engEvalString(ep, CommandChangePath);
Itβs very useful for me to put the desired MATLAB function in the current C ++ project, add the path and use it! Now you do not need to change the path at every step - it is always remembered and always useful for the current application.
source share