MATLAB: How to find out if a header file for a shared library can be used with the function LOADLIBRARY

dllMATLABverify

I would like to determine if a header file doesn't contain errors and if it can be used safely with the function LOADLIBRARY.

Best Answer

The shared library interface supports header files that contain legal C code. In order to test if a header file is a valid, you can create a temporary C file (with the extension .c), include the header and try to compile it.
If the compiler is able to compile the file, then the header file can safely be used with the function LOADLIBRARY. The attached file automates these steps and can be used as follows:
testlibraryheader header.h
The function LOADLIBRARY uses a compiler to parse the header file:
- On 32-bit Windows: LCC.
- On 64-bit Windows: The supported compiler as documented.
- On Linux: The supported compiler.
Before using this function to test your header file, run "mbuild -setup" and select the same compiler that LOADLIBRARY uses.