Will Matlab ever permit C++ DLL's?
28 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Kristoffer Walker
am 23 Feb. 2016
Beantwortet: Vivek
am 2 Okt. 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 Kommentare
Akzeptierte Antwort
Vivek
am 2 Okt. 2019
Hi,
We've introduced this capability in MATLAB starting in R2019a. Please take a look:
0 Kommentare
Weitere Antworten (2)
Guillaume
am 23 Feb. 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 Kommentare
Walter Roberson
am 23 Feb. 2016
No. Those are memory management contracts that conflict with MATLAB's memory management needs.
0 Kommentare
Siehe auch
Kategorien
Mehr zu Use Prebuilt MATLAB Interface to C++ Library finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!