title: What is the purpose of thunk file generated by matlab?
body: <p>When calling external C library (DLL) from matlab, it seems that matlab will first try to generate a thunk file named as <code>filename_thunk_pcwinXX.dll</code> (where XX is either 32 or 64 depend on the OS) in a temp directory.</p>
  
  <p>In matlab docs, it mentions that this file is an interface between external DLL and Matlab, so it doesnt not contain any other data of the original external DLL.</p>
  
  <p>The problem is, i have written a library that at runtime may call other libraries, matlab will always give me some wierd results or even crash when the library is calling certain libraries (not all, and  my library and other libraries here are 64-bit DLL).</p>
  
  <p>And all my library functions work flawlessly when being called from other C/C++ programs instead of matlab.</p>
  
  <p>I just wonder, in order to let matlab works properly, does these other libraries being called by my library at runtime need to get some sort of thunk file as well? I just cannot believe that, but I dont know the exact method of how matlab handle external libraries either.</p>