error C2440: cannot convert from const size_t* to const int*

912 views
Skip to first unread message

ALEXANDER P. Dumont

unread,
Mar 22, 2017, 8:02:05 AM3/22/17
to mcx-users
Hi Dr. Fang

I am getting this error when I try to compile mexFunction from MCX in Visual Studio. I just wanted to run it past you before I make any changes since you are much more intimate with the code.
Capture.PNG

Qianqian Fang

unread,
Mar 22, 2017, 12:56:20 PM3/22/17
to mcx-...@googlegroups.com
On 03/22/2017 08:02 AM, ALEXANDER P. Dumont wrote:
Hi Dr. Fang

I am getting this error when I try to compile mexFunction from MCX in Visual Studio. I just wanted to run it past you before I make any changes since you are much more intimate with the code.

hi Alex

I looked at the lines reported by your VS, I do not see any function calls
that involves const size_t and int pointers in the current github code.
for example, line#535 is simply a closing curly bracket

https://github.com/fangq/mcx/blob/master/src/mcxlab.cpp#L535

are you trying to compile an older version? if yes, which one?

Qianqian

--
You received this message because you are subscribed to the Google Groups "mcx-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mcx-users+...@googlegroups.com.
To post to this group, send email to mcx-...@googlegroups.com.
Visit this group at https://groups.google.com/group/mcx-users.
For more options, visit https://groups.google.com/d/optout.


ALEXANDER P. Dumont

unread,
Mar 22, 2017, 2:58:31 PM3/22/17
to mcx-users
Yes I was trying to compile v2016.4 release, I will look at compiling the newer version then! Thank you for your rapid help!

ALEXANDER P. Dumont

unread,
Mar 22, 2017, 7:34:37 PM3/22/17
to mcx-users
Aha I am having another problem now! 

Error 1 error C2664: 'mxArray *mxCreateNumericArray_730(size_t,const size_t *,mxClassID,mxComplexity)' : cannot convert argument 2 from 'int [4]' to 'const size_t *' c:\users\tub08918\google drive\patil lab\alexsfolderpleasevisitme\ramanmontecarlo\mcx-master\mcx-master\src\mcxlab.cpp 228 1 mcx

Which I think is due to the fact that my architecture is using mxCreateNumericArray_730 whereas you seem to be using mxCreateNumericArray_700, which uses the inputs yu put in but fails in my version. Any quick work arounds?

Qianqian Fang

unread,
Mar 22, 2017, 10:41:34 PM3/22/17
to mcx-...@googlegroups.com
On 03/22/2017 07:34 PM, ALEXANDER P. Dumont wrote:
Aha I am having another problem now! 

Error 1 error C2664: 'mxArray *mxCreateNumericArray_730(size_t,const size_t *,mxClassID,mxComplexity)' : cannot convert argument 2 from 'int [4]' to 'const size_t *' c:\users\tub08918\google drive\patil lab\alexsfolderpleasevisitme\ramanmontecarlo\mcx-master\mcx-master\src\mcxlab.cpp 228 1 mcx

you can try inserting (const size_t*) right in front of the second input
of all occurrences of mxCreateNumericArray. This will force converting
the fielddim array to the required pointer type.


Which I think is due to the fact that my architecture is using mxCreateNumericArray_730 whereas you seem to be using mxCreateNumericArray_700, which uses the inputs yu put in but fails in my version. Any quick work arounds?

mcxlab source never specifies a particular version of matlab.
it must have been your compiler/matlab integration problem.

ALEXANDER P. Dumont

unread,
Mar 23, 2017, 10:05:36 AM3/23/17
to mcx-users
Hi Dr. Fang 

I got it working! Thanks for the help!

Qianqian Fang

unread,
Mar 23, 2017, 11:47:57 AM3/23/17
to mcx-...@googlegroups.com
On 03/23/2017 10:05 AM, ALEXANDER P. Dumont wrote:
Hi Dr. Fang 

I got it working! Thanks for the help!

glad to know it works now.

do you mind sharing your VS proj/sln file for mcxlab? I only managed to create
a VS project for compiling MCX binary, but not yet able to do this for MCXLAB.
I am happy to include your proj/sln file in the next release of MCX.

thanks

Qianqian

ALEXANDER P. Dumont

unread,
Mar 23, 2017, 2:41:53 PM3/23/17
to mcx-users
Sure! I will provide a package after I cleaned up my code. Where should I post it?

Qianqian Fang

unread,
Mar 23, 2017, 11:00:44 PM3/23/17
to mcx-...@googlegroups.com
On 03/23/2017 02:41 PM, ALEXANDER P. Dumont wrote:
Sure! I will provide a package after I cleaned up my code. Where should I post it?

feel free to email me directly, or post with this thread, or fork mcx on github,
add your tested project file, and send me a "pull request".

https://help.github.com/articles/about-pull-requests/
https://help.github.com/articles/fork-a-repo/

any of these is good.

ALEXANDER P. Dumont

unread,
Apr 2, 2017, 8:47:37 AM4/2/17
to mcx-users
Hi Dr. Fang sorry about the long break. I am succesfully compiling MCX in Visual Studio into a mex file. However, when I test the mex file is when all hell breaks lose. MATLAB crashes, I am trying to debug the code but havent had much time lately, but will get onto it in April
Reply all
Reply to author
Forward
0 new messages