Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
mxCreateDoubleMatrix fails in DLL

Subject: mxCreateDoubleMatrix fails in DLL

From: Vojtech Drabek

Date: 9 Jul, 2014 17:14:16

Message: 1 of 2

Hi,

I am trying MATLAB engine and successfully compiled and run engwindemo.c. Then I created a simple DLL with a function with this signature:

extern "C" __declspec( dllexport ) int __stdcall my_main (const int nr, const double *arr, double* arr2)

The DLL works fine without the MATLAB functions. It works when I add the MATLAB engine initialization, even engEvalString with plot works fine, MATLAB is launched and the plot is shown. But if I add mxCreateDoubleMatrix, just like in engwindemo.c, it returns NULL. I do not know how it could be a memory issue, malloc() easily allocates a megabyte, mxCreateDoubleMatrix fails on 1x10 real matrix. Is there any other reason why it should fail?

Thanks,
Vojtech Drabek

Subject: mxCreateDoubleMatrix fails in DLL

From: James Tursa

Date: 9 Jul, 2014 19:58:11

Message: 2 of 2

"Vojtech Drabek" <vdrabek@centrum.cz> wrote in message <lpjt98$1sl$1@newscl01ah.mathworks.com>...
> Hi,
>
> I am trying MATLAB engine and successfully compiled and run engwindemo.c. Then I created a simple DLL with a function with this signature:
>
> extern "C" __declspec( dllexport ) int __stdcall my_main (const int nr, const double *arr, double* arr2)
>
> The DLL works fine without the MATLAB functions. It works when I add the MATLAB engine initialization, even engEvalString with plot works fine, MATLAB is launched and the plot is shown. But if I add mxCreateDoubleMatrix, just like in engwindemo.c, it returns NULL. I do not know how it could be a memory issue, malloc() easily allocates a megabyte, mxCreateDoubleMatrix fails on 1x10 real matrix. Is there any other reason why it should fail?
>
> Thanks,
> Vojtech Drabek

Can't say from your description. Can you post the code? How are you calling the functions in this DLL? loadlibrary or ...?

James Tursa

Tags for this Thread

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

Contact us