Azzera filtri
Azzera filtri

Building a MEX function that depends on a .dll, .lib, and headers?

38 visualizzazioni (ultimi 30 giorni)
Hello,
I have a C++ function that depends on a.dll, a.lib (import library), and some include directory. This function works fine in Microsoft Visual Studio as I can tell MSVC where my headers and libraries are.
I have put this functionality inside a "MEXFunction" and I would like to build it so that it's accessible form MATLAB. However, I don't know how to tell mex to link against third party dll, lib, and header files.
Thanks for any assistance!

Risposte (1)

Maadhav Akula
Maadhav Akula il 4 Nov 2019
  1 Commento
Baptiste
Baptiste il 11 Mar 2024
Hi ! I took a look on those links but I'm still in the fog because I don't see how useful is the .dll file here while you call directly the library...
So here a resume :
1) From a project in another folder, whee the are already a complete and working project, I generated a c++ dll file using a visual dll project, let's call it "Lena.dll"
2) I create another folder for matlab simulink and create "lena.c" with the S-functions calling the c++ functions I know from the project, and "MexLena.m" where there are the following lines :
mex -v -g Lena.c Lena.lib
3) I put "Lena.dll" in the same folder than "Mexlena.m"
---> Don't work ! It request the Lena.lib
4) So I move Lena.lib in the folder :
---> Don't work ! It request the headers of the projec.
5) I move the headers, but I think seriously that normally, only the dll must be enought to work for the software
---> Work !
6) Delete the dll to see if I really use the dll file
--> Work too, so I don't use the dll in fact....
What to do to use the dll without moving the library and the headers from the other folder ? :/
Where I do the misstep ? At 4) ?

Accedi per commentare.

Categorie

Scopri di più su Write C Functions Callable from MATLAB (MEX Files) in Help Center e File Exchange

Prodotti


Release

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by