Will Matlab ever permit C++ DLL's?
27 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Kristoffer Walker
el 23 de Feb. de 2016
Respondida: Vivek
el 2 de Oct. de 2019
Folks,
I have C++ specific functions (I use a lot of templates and overloading) that I would like to be able to use on a continuous basis from Matlab. However, these things cannot be "extern C'd" to use them with loadlibrary. I really am not a fan of having to create a special interface using Mex, because I want to use the same API for all Applications that call my library DLL's (efficient this way, and permits using Matlab to test the library functions using the same API).
Will Matlab in the future ever permit using loadlibrary with true C++ DLL's without extern C wrappers?
Thanks, Kris Walker
0 comentarios
Respuesta aceptada
Vivek
el 2 de Oct. de 2019
Hi,
We've introduced this capability in MATLAB starting in R2019a. Please take a look:
0 comentarios
Más respuestas (2)
Guillaume
el 23 de Feb. de 2016
No, it's not going to happen. It's not possible.
It's not an issue specific to matlab. It's all to do with the fact that C++ does not have a standardised ABI. This means that in practice a C++ program (or dll) compiled with compiler A cannot talk to a C++ program (or dll) compiled with compiler B.
Even different versions of the same compiler, or different compilation switches with the same version are enough to break the ABI. If you try to call a C++ dll compiled with Visual Studio 12 from an executable compiled with Visual Studio 13, in all likelyhood it's going to crash. Particularly if you're using templates / exceptions / polymorphism / TMP and all the nice features of C++.
The whole purpose of the extern "C" wrappers is to make it possible for the programs to talk to each other.
0 comentarios
Walter Roberson
el 23 de Feb. de 2016
No. Those are memory management contracts that conflict with MATLAB's memory management needs.
0 comentarios
Ver también
Categorías
Más información sobre Use Prebuilt MATLAB Interface to C++ Library en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!