mxCreateDoubleMatrix returns NULL when called from C program on a system using MCR
Show older comments
Hi,
mxCreateDoubleMatrix returns NULL when called from a C/C++ console program? My system setup as such:
Win 7
Matlab 4.16
MCR 1.16
C shared library compiled by MATLAB Compiler 4.16 (R2011b)
I've linked the mclmcrrt.lib and <myCompiled m file>.lib and dll--not sure if more are required?
Thanks for your input.
Answers (2)
Kaustubha Govind
on 24 May 2012
0 votes
What arguments do you pass into mxCreateDoubleMatrix? If your applications compiles and links property, and doesn't have other run-time errors, I wouldn't worry about the .lib and .dll files. On the other hand mxCreateDoubleMatrix allocates memory on the heap, so one situation where it may return NULL is when your application is out of memory. You are trying to create a very large matrix perhaps? I would recommend try to use "new" to allocate the same amount of memory and see if it throws the bad_alloc exception.
4 Comments
KME
on 24 May 2012
James Tursa
on 24 May 2012
If t is NULL then you shouldn't do any downstream processing using it. E.g., mxGetPr(t) should not be called if t is NULL, etc.
KME
on 24 May 2012
Arjun
on 2 Aug 2013
was this issue resolved?
Edgar
on 24 May 2012
0 votes
Try to call mclInitializeApplication(NULL,0); at the beginning of your app.
Categories
Find more on C Shared Library Integration in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!