For Windows PCs:
Use "Dependencies"
The application Dependencies is a free, open source tool that scans 64-bit Windows modules (e.g., .mexw64, .dll, .exe) 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. Dependencies was developed as an alternative to Dependency Walker and works almost exactly the same as Dependency Walker but is faster and has been updated to find the Windows System files.
To start the tool, download the zip file from the linked site, unzip it, and run "DependenciesGui.exe". To see the dependencies of a .dll or .mexw64 file, use the "File" > "Open" menu options or drag and drop the file into the tool's main window. The tool will show your library dependencies and use colors to highlight interesting ones (red for broken/missing libraries, for example). Notes:
1) If MEX MATLAB dependencies (e.g., libmex.dll and libmx.dll) are flagged as missing, this generally indicates that Dependencies doesn't have the necessary path information to locate these files, which are located in "<matlabroot>\bin\win64". In this case, there are three options to resolve the "missing' MEX MATLAB dependencies.
- Add the appropriate MATLAB paths to the Windows system PATH. Be sure to restart Dependencies after doing so.
- Add the appropriate MATLAB paths in Dependencies using "Options" > "Customize search folders".
- Launch Dependencies from MATLAB, so Dependencies inherits MATLAB path information.
! <path-to-Dependencies>\DependenciesGui.exe
2) Some Windows DLLs (e.g., api-ms-win-core-rtlsupport-l1-2-2.dll) are actually Windows API set names that represent a virtual alias for a physical .dll file. Since they cannot be resolved in a static analysis tool, such as Dependencies, they may get flagged as "missing".
3) Dependencies also has a command-line tool. To see the options execute the following command in a Windows terminal.
<path-to-dependencies>\dependencies.exe -help
Use "dumpbin"
If you have Visual Studio or Build Tools for Visual Studio installed, you can use dumpbin to determine your run-time library dependencies. For example,
dumpbin /dependents libname.dll
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: