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

31 次查看(过去 30 天)
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!

回答(1 个)

Maadhav Akula
Maadhav Akula 2019-11-4
  1 个评论
Baptiste
Baptiste 2024-3-11
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) ?

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Get Started with MATLAB 的更多信息

产品


版本

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by