I try to use a c-shared library from the matlab (2017a) compiler in VC++ 2017. the call to the initialize function of the dll crashes.

3 vues (au cours des 30 derniers jours)
I created a simple dll called TestMatlabDLL with matlab compiler 2017a. I created a visual studio 2017 console application and tried to load the dll. I included TestMatlabDLL.h/.c/.lib/.dll to the VS project according to many different documentations. The compilation/linking process shows no errors or warning. But whatever I do, the call to TestMatlabDLLInitialize() crashes. I would also appreciate if somebody could send me or point me to a sample Visual Studio project that uses a Matlab dll (preferrably everything version 2017).

Réponses (2)

Markus Schiefele
Markus Schiefele le 30 Mai 2017
I can now answer at least a part of my question myself. In my first version I did not have a call to mclRunMain. As a consequence of this, TestMaylabDLL.dll was not loaded. Adding mclRunMain to my code however did not improve my situation significantly. Now I am getting a linker error (LNK2005) for a double defined symbol called times2 (the function I want to export). Looking at TestMatlabDLL.dll (in DependencyWalker) and TestMatlabDLL.cpp I am afraid I must agree with the linker: times2 is defined in both! Does somebody have a similar experience? Can this be a Matlab bug? Did anybody get a Matlab compiler C/C++ shared library to run under Visual Studio 2017? Any kind of help is greatly appreciated.

Riccardo Fossati
Riccardo Fossati le 10 Juin 2017
Modifié(e) : Riccardo Fossati le 10 Juin 2017
Hi Markus, I have encountered a problem similar to yours while trying to run the code I wrote in VS2013 that links to a function in Matlab R2016a. Have you found some kind of solution? Thanks a lot
Riccardo Fossati

Catégories

En savoir plus sur C Shared Library Integration 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!

Translated by