Open danielRuckser opened 6 years ago
Thanks for this, it solved some build issues I was having as well.
I added the #define to the mex command:
mex -I../include -I../third_party -I../third_party/eigen3 -L../build/lib -lopengv opengv.cpp -DmxCreateNumericArray=mxCreateNumericArray_700
which saves having to modify any code (even if it's a minor modifcation)
I solved this compilation problem using this flag "mex -DMX_COMPAT_32 ..."
I solved this compilation problem using this flag "mex -DMX_COMPAT_32 ..."
It works for me. But when I run edgesDemo.m, I got an error: cannot find 'imPad' in edgesDetect.
I solved this compilation problem using this flag "mex -DMX_COMPAT_32 ..."
It works for me. But when I run edgesDemo.m, I got an error: cannot find 'imPad' in edgesDetect.
solved
Within MATLAB R2017b it is not possible to build the MEX files as explained. A quick successful workaround is at the end of this comment!
Used Hardware and Software: -> Mac Book Pro (Retina, 15inch, Mid 2014) -> macOS High Sierra, Version 10.13.1 -> Xcode Version 9.1 (9B55) -> MATLAB R2017b, Version 9.3.0.713579
I built the binaries with "cmake" as described in the reference.
Then the MATLAB MEX commands were as follows: 1) mex -setup C++ 2) cd /Applications/opengv/matlab 3) mex -I../include -I../third_party -I../third_party/eigen3 -L../build/lib -lopengv opengv.cpp
Output of MATLAB was:
There were a lot of similar error messages like this one. Reason for this is the function "mxCreateNumericArray" that is called several times in "opengv.cpp" (that is located in opengv/matlab).
I assume an upward compatibility issue with more recent MATLAB versions like mine (R2017b). You can find the relevant MATLAB file in "MATLAB_R2017b.app/extern/include", it is named "matrix.h".
In this file the there are two relevant functions:
mxCreateNumericArray_730(size_t ndim, const size_t *dims, mxClassID classid, mxComplexity flag)
andmxCreateNumericArray_700(int ndim, const int *dims, mxClassID classid, mxComplexity flag)
.Suitable pre-processor macros are also implemented in "matrix.h" to call "mxCreateNumericArray_730 " every time "mxCreateNumericArray" is called (without "_7xx" in the name). As easily seen these two functions have different input argument types. "int" & "const int" in the one case (which are signed types) and "size_t" & "const size_t" in the other case (which are unsigned types).
MATLAB is therefore unable to do a proper type conversion on its own. As a quick workaround in order to prevent you from changing many lines of code I recommend adding following line in the top of the file "opengv.cpp" (that is located in opengv/matlab):
#define mxCreateNumericArray mxCreateNumericArray_700
.That will force MATLAB to use the (older) function "mxCreateNumericArray_700" with proper input argument types. After doing that everything seems to work fine.