Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Do you have any idea how to solve the following error? #24

Closed
yxchng opened this issue Jun 8, 2017 · 5 comments
Closed

Do you have any idea how to solve the following error? #24

yxchng opened this issue Jun 8, 2017 · 5 comments

Comments

@yxchng
Copy link

yxchng commented Jun 8, 2017

>> mex compute_dense_overlap.cc CXXFLAGS='$CXXFLAGS -fopenmp' ...
LDFLAGS='$LDFLAGS -fopenmp' CXXOPTIMFLAGS='-O3 -DNDEBUG' 
Building with 'g++'.
Error using mex
/home/yxchng/tiny/utils/compute_dense_overlap.cc: In function ‘void mexFunction(int, mxArray**,
int, const mxArray**)’:
/home/yxchng/tiny/utils/compute_dense_overlap.cc:70:77: error: cannot convert ‘const int*’ to
‘const size_t* {aka const long unsigned int*}’ for argument ‘2’ to ‘mxArray*
mxCreateNumericArray(size_t, const size_t*, mxClassID, mxComplexity)’
   mxArray *mx_overlap = mxCreateNumericArray(4, dims, mxDOUBLE_CLASS, mxREAL);
                                                                             ^
/home/yxchng/tiny/utils/compute_dense_overlap.cc:75:38: warning: narrowing conversion of
‘(((double)((int)vsy + -1) * ((double)zmy)) + 1.0e+0)’ from ‘double’ to ‘const int’ inside { }
[-Wnarrowing]
   const int tmp_dims[] = {(vsy-1)*zmy+1, (vsx-1)*zmx+1, nt};
                                      ^
/home/yxchng/tiny/utils/compute_dense_overlap.cc:75:53: warning: narrowing conversion of
‘(((double)((int)vsx + -1) * ((double)zmx)) + 1.0e+0)’ from ‘double’ to ‘const int’ inside { }
[-Wnarrowing]
   const int tmp_dims[] = {(vsy-1)*zmy+1, (vsx-1)*zmx+1, nt};
                                                     ^
/home/yxchng/tiny/utils/compute_dense_overlap.cc:76:85: error: cannot convert ‘const int*’ to
‘const size_t* {aka const long unsigned int*}’ for argument ‘2’ to ‘mxArray*
mxCreateNumericArray(size_t, const size_t*, mxClassID, mxComplexity)’
   mxArray *mx_tmp_overlap = mxCreateNumericArray(3, tmp_dims, mxDOUBLE_CLASS, mxREAL);
                                                                                  ^
@yxchng
Copy link
Author

yxchng commented Jun 8, 2017

Solved. You are using 32bit system I think, so I need to compile mex with "mex -DMX_COMPACT_32"

@yxchng yxchng closed this as completed Jun 8, 2017
@peiyunh
Copy link
Owner

peiyunh commented Jun 9, 2017

I'm not sure why you had to compile with that option, but I'm glad you solved it. My system is 64-bit. What's the version of MATLAB that you are using?

@myungsub
Copy link

myungsub commented Jul 26, 2017

I had the same error, but couldn't solve it by adding the 32-bit option.
Instead, solved it by changing to the cross-platform type mwSize in the mex file compute_dense_overlap.cc. (Followed this)
On line 67:
const int dims[] = {vsy, vsx, nt, ng}; --> const mwSize dims[] = {vsy, vsx, nt, ng};
Same on line 75 with tmp_dims[].

I'm using MATLAB 2017a on Ubuntu 16.04. Hope it helps someone else who use this code!

@varunagrawal
Copy link

@peiyunh can you please add this to the README?
I encountered the same issue and @myungsub's solution worked.
I'm using MATLAB 2017b 64-bit and had this issue as well.

peiyunh added a commit that referenced this issue Feb 6, 2018
change int to mwSize (thanks to #24 (comment))
@peiyunh
Copy link
Owner

peiyunh commented Feb 6, 2018

@varunagrawal Yes! Thanks for reminding me to do so.

@myungsub Thanks for pointing out the solution. I've updated the source code.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants