ali ebrahimi
ali ebrahimi

Reputation: 1

how use dll files in C++?

I need generate Dll file from matlab cods and use this in C++. I can not couple dll file in c++. Please help me.

Upvotes: 0

Views: 663

Answers (1)

foraidt
foraidt

Reputation: 5689

This looks promising: How do I create a C - shared library with MATLAB Compiler 3.0 which can be used in other projects?

In short:

  1. Compile your MATLAB files into a DLL (on Windows): mcc -t -L C -W lib:mylib -T link:lib -h <MATLAB files> libmmfile.mlib

  2. Add mylib.lib to your MSVC (or your own IDE) project

  3. Make sure to call the initialization and termination routines from your code before calling any of the MATLAB files that are compiled. You need to call: mylibInitialize();
    Afterwards, you should call the termination routine: mylibTerminate();
    All of the symbols in mylib.dll will also appear in mylib.h.

  4. You can call the functions compiled from the MATLAB code by invoking mlfFoo(...), from your C code.

Upvotes: 3

Related Questions