On Windows, I am building a mex function "myFcn_mex" which links to a DLL "myLib.dll" via an import library "myLib.lib". I have the following directory structure:
My Matlab code looks as follows:
projectBase = getenv('MY_PROJECT_BASE');
includePath = [projectBase filesep 'src' filesep 'include'];
libPath = [projectBase filesep 'bin' filesep 'win' filesep 'x86_64'];
libName = 'myLib.lib';
In Matlab I do this:
[Line 1] >> addpath([getenv('MY_PROJECT_BASE') filesep 'bin' filesep 'win' filesep 'x86_64']);
[Line 2] >> cd(getenv('MY_PROJECT'));
[Line 3] >> codegen myFcn
[Line 4] >> myFcn
- DLL and LIB files live in a folder which has been succesfully added to Matlab path [Line 1]
- Folder where dll and lib files reside is not the same where I need to create my mex function [Line 2]
- Codegen command successfully runs and creates the file myFcn_mex.mexw64 in my working directory [Line 3]
- Calling the mex function [Line 4] results in error:
Missing dependent shared libraries:
'myLib.dll' required by
The function call suceeds if I copy the DLL locally:
>> !cp %MY_PROJECT_BASE%\bin\win\x86_64\myLib.dll .\
I quite clearly remember that in the past just adding the directory where dll file resides to the Matlab path used to work. It no longer seems to be the case. I either have to have this DLL in my current directory or on the OS path, which would require me to exit Matlab, change the OS Path environmant variable, and then restart Matlab.
- Is there not another way of managing a DLL? I do not want to do either of the two options I described above.
- How different would be the way to do that with a myLib.so file on Linux or myLib.dylib on Mac?
Thanks in advance