Closed oayhan1 closed 6 years ago
It seems a VS2010 issue. Is your visual studio up-to-date (patches, service pack, etc.)?
The same issue was reported before (#16), but the ticket somehow disappeared.. (maybe original user deleted their account?)
Anyway, I recovered the discussion using Google cache, which I quote below for the record.
Please try the suggested solutions and report if the problem is fixed
Problem with visual studio 2010
newbie19 opened this issue September 08, 2012
I tried mexopencv using Matlab 2010a, opencv 2.4.2, and visual studio 2010, then I got following problem:
MxArray.cpp C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\yvals.h(576) : error C2371: 'char16_t' : redefinition; different basic types c:\program files\matlab\r2010a\extern\include\matrix.h(330) : see declaration of 'char16_t'
By googling I learned that this problem occurs since I used visual studio 2010. There are many suggested solutions here: http://www.mathworks.com/matlabcentral/newsreader/view_thread/281754 but I don't know how to implement it for mexopencv.
The first error happened in MxArray.cpp , but I cannot find any line that called matrix.h.
So, can somebody help me here?
amroamroamro commented September 08, 2012
What do you get when you try to compile a minimalistic MEX function?
#include "mex.h" void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]) { mexPrintf("test\n"); }
Save the above in a C++ file textMEX.cpp, and compile it using mex testMEX.cpp
In case of problems, the following section found towards the end of tmwtypes.h could be the cause of your issues:
$MATLABROOT\extern\include\tmwtypes.h
/** UTF-16 character type */ #if defined(__STDC_UTF_16__) || (defined(_HAS_CHAR16_T_LANGUAGE_SUPPORT) && _HAS_CHAR16_T_LANGUAGE_SUPPORT) typedef char16_t CHAR16_T; #elif defined(_MSC_VER) typedef wchar_t CHAR16_T; #else typedef UINT16_T CHAR16_T; #endif
This file is included by "matrix.h" which is in turn included by "mex.h" (required by all MEX files)
(I am using R2012a on WinXP+VS2010 and I have no problems compiling)
kyamagu commented September 08, 2012
Do you install Windows SDK? You say you're using vs2010 win64 but at least your compiler seems to be x86. Make sure you're using 64-bit compiler in Matlab 64-bit and also run mex -setup to choose Win SDK for the compiler.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\yvals.h(576) : error C2371: 'char16_t' : redefinition; different basic types c:\program files\matlab\r2010a\extern\include\matrix.h(330) : see declaration of 'char16_t'
amroamroamro commented September 08, 2012
Also VS2010 was only officially supported starting at MATLAB R2010b, although there is a patch available for R2010a. Perhaps you should consider updating MATLAB if possible..
As a quick fix, try editing MxArray.hpp, and move mex.h after the other includes with:
#ifdef _CHAR16T #define CHAR16_T #endif #include "mex.h"
Some more references found here and here.
kyamagu closed the issue November 07, 2012
I expreienced errors when compilation process.I use opencv 2.4.4 matlab r2010a and visual studio 2010. What's wrong?