Will Matlab ever permit C++ DLL's?

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

采纳的回答

Vivek
Vivek 2019-10-2
Hi,
We've introduced this capability in MATLAB starting in R2019a. Please take a look:

更多回答(2 个)

Guillaume
Guillaume 2016-2-23
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.

Walter Roberson
Walter Roberson 2016-2-23
No. Those are memory management contracts that conflict with MATLAB's memory management needs.

类别

Help CenterFile Exchange 中查找有关 Use Prebuilt MATLAB Interface to C++ Library 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by