I would like to use a toolbox containing .m functions and (pre-compiled) .mex files.
The path containing both the function and the mex file are included in the search path. I verified that Matlab can see the function, as help functionname returns the correct help file.
When I try to run some code calling one of the functions, I get the error:
"Invalid MEX-file 'C:\somepath\mexfilename.mexw64': The specified module could not be found."
Note, that it could find the function, but not the mex file located in the same directory as the function.
If I remove the directory from the search path, it (obviously) cannot find the function either, creating a different error:
"Undefined function 'functionname' for input arguments of type 'char'."
The strange thing is, that when I set the working directory to the location where the function and the mex file are, everything works.
But, as mentioned, if the directory is only in the search path, but not currently the working directory, it can find the function, but not the mex file.
Seeing that the code runs perfectly well if the working directory points at the mex fiel, I would exclude all problems related to compilation and/or running of the mex files. I think the problem is with the path / visibility of the file, but then why does it see the function?
I recently switched computers. On my former computer I already used the same toolbox and did not run into this problem (Matlab 2018b on win10 in both cases).