For Windows PCs:
Dependency Walker is a free utility that scans any 32-bit or 64-bit Windows module (.exe, .dll, .ocx, .sys, etc.) and builds a hierarchical tree diagram of all dependent modules. For each module found, it lists all the functions that are exported by that module, and which of those functions are actually being called by other modules.
Launch Dependency Walker:
2. Open MATLAB and issue a call to the "depends" executable that comes with Dependency Walker.
NOTE: The following assumes that you have installed Dependency Walker in D:\Depends.
To search the dependencies for the MEX-file "myMexFile", use:
!D:\Depends\depends.exe myMexFile
To search the dependencies for the stand-alone application "myApp.exe", use:
!D:\Depends\depends.exe myApp.exe
Alternatively, you can also use the following syntax and redirect the output from Dependency Walker to a text file.
!D:\Depends\depends.exe /c /f:1 /of:C:\Temp\SomeUniqueFileName.txt myMexFile
!D:\Depends\depends.exe /c /f:1 /of:C:\Temp\SomeUniqueFileName.txt myApp.exe
In this command, replace "C:\Temp\SomeUniqueFileName.txt" by the full path of a text file to which Dependency Walker will write the output.
Once the text file has been generated, you can search in it for reports of any missing libraries.
Create runtime Dependency Walker profiles (.DWI-files):
In addition to loading libraries directly through dependencies, stand-alone executables generated by MATLAB and MATLAB Compiler load a number of libraries dynamically at runtime. Static analysis tools do not show these libraries. You can use Dependency Walker to create runtime Dependency Walker profiles (.DWI-files) that can then be used to determine the runtime library dependencies for your MEX-file or stand-alone executable. You can create profiles as follows after launching Dependency Walker:
- Click File > Open and select your stand-alone executable or MEX-file.
- Ensure that View > Full Paths is selected.
- Click Profile > Start Profiling.
- Click File > Save As to save the file as a .DWI-file.
Alternatively:
- Click File > Open and select $MATLAB\bin\win64\matlab.exe to launch MATLAB (where $MATLAB is the MATLAB root directory on your machine, as returned by typing "matlabroot" at the MATLAB Command Prompt).
- Go to the Profile menu and select "Start Profiling." Press OK or choose some advanced options.
- This will create a profile and start MATLAB
- In MATLAB, execute your MEX-file or stand-alone executable.
- Switch to Dependency Walker and, if necessary, click Window > MATLAB.EXE to select MATLAB history.
- Click File > Save As to save the file as a .DWI-file.
For UNIX:
You can use either the 'nm' or the 'ldd' utility to determine static file dependencies.
The nm utility lists the symbols for each object file that is specified by the filename passed to it as an argument.
If no symbolic information is available for a valid input file, the nm utility reports that fact but does not consider it an error condition. For more information, type 'man nm' at a shell prompt.
The ldd utility lists the dynamic dependencies of executable files or shared objects. It lists the path names of all shared objects that are loaded when the specified filename is loaded. For more information, type 'man ldd' at a shell prompt.
At the MATLAB Command Prompt, type
!nm -u myMexFile > /tmp/SomeUniqueFileName.txt
or
!ldd -U myMexFile > /tmp/SomeUniqueFileName.txt
In these examples, replace "/tmp/SomeUniqueFileName.txt" by the full path of a text file to which the output will be written, and replace "myMexFile" by the MEX-file whose dependencies you are searching for.
Once the text file has been generated, you can search in it for reports of any missing libraries.
If the output in the text file does not help narrow down your problem, here are some other things you can try.
1. Simplify the code from which you are generating your MEX-file or stand-alone application.
2. Compile the example files shipped with MATLAB. These examples are located in $MATLAB/extern/examples/compiler for stand-alone executables and $MATLAB/extern/examples/mex for MEX-files (where $MATLAB is the MATLAB root directory on your machine, as returned by typing "matlabroot" at the MATLAB Command Prompt).
3. Use nm or ldd to create the text file described above. Send all relevant text files to support@mathworks.com.
You can use the LD_DEBUG environment variable to evaluate the runtime library dependencies. Setting this variable to 'libs' instructs the dynamic linker to list the search path and result for all libraries loaded at runtime. For more information on the LD_DEBUG variable, see: