Where are the compiled THUNK files located and how to re-use them?

19 views (last 30 days)
Hi All;
I am having trouble locating where the 64-bit THUNK files are located on my Windows 7 laptop when using LOADLIBRARY. The documentation states the default naming convention but not where they reside on my hard-drive.
I am using the default MinGW compiler.
Also, I am interested in knowing how to compile once and then to re-use these THUNK files as the time to re-compile each time LOADLIBRARY is called seems excessive especially given that I have 7 DLL's that are needed to be loaded each time.
Kindest regards, Jeff

Accepted Answer

Image Analyst
Image Analyst on 28 Jul 2016
Jeffrey, you have to create the thunk file - it doesn't ship with MATLAB, at least not a custom thunk file for your custom DLL. My attached well-commented file where I had to create one may help you.

More Answers (1)

Philip Borghesani
Philip Borghesani on 28 Jul 2016
If you specify the mfilename option to loadlibrary then the thunk file will be created in the same directory as the prototype file and used when the prototype file is used to load the library. By default the thunk file is placed next to the prototype file in a temporary directory created inside tempdir. It is also possible to override the thunkfilename with a second option to loadlibrary.
  2 Comments
Jeffrey D Kelly
Jeffrey D Kelly on 28 Jul 2016
Hi Philip;
Thanks - however I checked my temp directory (%USERPROFILE%\AppData\Local\Temp) and the THUNK DLL is not there.
Also, I am using LOADLIBRARY as follows and I am not using a prototype file but a header file i.e.,
loadlibrary('IMPLserver.dll','IMPLservermatlabinclude.h');
Any thoughts?
Thanks - Jeff
Philip Borghesani
Philip Borghesani on 28 Jul 2016
Edited: Philip Borghesani on 28 Jul 2016
The thunk file is placed in a directory that is named with the tempname MATLAB command. The file generated into the temp directory is deleted when the library is unloaded or MATLAB exits. Specifying mfilename changes the location and prevents it from being cleaned up. If you still want to find it I suggest using process explorer from sysinternals and searching for the dll when you have it loaded into matlab.

Sign in to comment.

Categories

Find more on MATLAB Compiler in Help Center and File Exchange

Products

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!