How to compile a DLL and header file?

3 views (last 30 days)
Mohd Harish
Mohd Harish on 5 May 2014
Edited: Chaitra on 25 Jun 2014
I am trying to create a compiled standalone application that uses a DLL driver to work with an FTDI chip. The driver runs on Windows 64 bit. The driver a header file called ftd2xx64.h)
I first tried just adding this file and all my m files into my MATLAB Compiler (R2013b) and compiling. I got an error that my .h file could not be compiled without an "-a" option.
Then I tried compiling the m files by themselves and copy/pasting the .h file into the for_testing folder that was created along with my standalone application. When I tried running the app, I got an error message stating that I need to use a prototype file instead of a header file. MATLAB says I can create a prototype file by using the "loadlibrary" command with an 'mfilename' option.
Is this what I need to do to include this .h file in my app? If so, how do I make this prototype file exactly?

Answers (1)

Chaitra
Chaitra on 25 Jun 2014
Edited: Chaitra on 25 Jun 2014
All the files(header or dll or any other files) that are needed by a ".m" file to run can be compiled along with the ".m" file by using -a flag in mcc command.
>> mcc –m foo.m [-a filename...]
You can learn more about the usage of -a flag by executing the following command in MATLAB:
>> docsearch mcc -a
You cannot copy/paste .h file into for_testing folder, because when the compiled application runs it needs to know the location of the header file in memory. Deployable MATLAB files are suspended or frozen at the time MATLAB Compiler encrypts them—they do not change from that point onward. When the application is compiled without the header file, there is no way for the application to determine the physical location of header file in memory.

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!