Mixing compiled matlab shared libraries with mex code.
Ältere Kommentare anzeigen
I have some matlab code that invokes mex code (compiled with VS2013). I have both Debug and Release builds of the mex code, and can adjust my system (windows) PATH prior to starting up Matlab so that when I invoke that mex function from Matlab, it invokes the desired build configuration.
Now, I want to bundle up the matlab code into a DLL with the matlab compiler. If I don't add the mex DLLs as additional files required in the .PRJ GUI, the compiled matlab code can't find it at runtime. But if I do add the mex code, the resulting compiled matlab library is "build configuration dependent" -- i.e. if I added the debug build of the mex code, the library won't work from a release build of an executable program client of the compiled matlab library, and vice versa. So, what I want to do is to get a compiled matlab library that doesn't know about the mex code, but which can find it at runtime using the normal PATH-related load procedure, since the desired mex DLL will be in the same folder (Debug or Release) as the executable program client of the compiled matlab library. But I don't seem to be able to find a way to accomplish this goal. Any thoughts?
Antworten (2)
Dasharath Gulvady
am 21 Jul. 2015
0 Stimmen
The best way to do this is to place the MEX file in a relative path to "ctfroot":
Normally, in Windows, "ctfroot" is %temp%\username\mcrCachexx.
4 Kommentare
Chris Volpe
am 21 Jul. 2015
Bearbeitet: Chris Volpe
am 21 Jul. 2015
Dasharath Gulvady
am 24 Jul. 2015
Bearbeitet: Dasharath Gulvady
am 24 Jul. 2015
You do not have to use a hardcoded location to copy the MEX file. You can set-up a Windows environment variable to point to a location where MEX file is placed. You can read the same environment variable in your MATLAB code to read the environment variable and make use of the MEX file
Chris Volpe
am 17 Sep. 2015
Bearbeitet: Chris Volpe
am 18 Sep. 2015
Adam Callens
am 5 Apr. 2017
What about the A.mexw64.auth file that is not generated if you don't include the mex file in the mcc build. How do you get around that?
Chris Volpe
am 18 Sep. 2015
0 Stimmen
Kategorien
Mehr zu Write C Functions Callable from MATLAB (MEX Files) finden Sie in Hilfe-Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!