Will Matlab ever permit C++ DLL's?
18 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kristoffer Walker
le 23 Fév 2016
Réponse apportée : Vivek
le 2 Oct 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 commentaires
Réponse acceptée
Vivek
le 2 Oct 2019
Hi,
We've introduced this capability in MATLAB starting in R2019a. Please take a look:
0 commentaires
Plus de réponses (2)
Guillaume
le 23 Fév 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 commentaires
Walter Roberson
le 23 Fév 2016
No. Those are memory management contracts that conflict with MATLAB's memory management needs.
0 commentaires
Voir également
Catégories
En savoir plus sur Deploy to C++ Applications Using mwArray API (C++03) dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!