Hi,
I am trying to compile C dll deployment matlab code with vs2010 and i run into the error below:
error C2371: 'char16_t' : redefinition; different basic types
May I know if there is a way to avoid this. I am using MCR 7.11
Thank you.
|
|
0
|
|
|
|
Reply
|
Chee
|
5/10/2010 5:48:25 PM |
|
Hello,
I have the same problem too. I am using VS2010 with MATLAB 2008b. Here is the exact error message:
c:\program files\matlab\r2008b\extern\include\matrix.h(346): error C2371: 'char16_t' : redefinition; different basic types
c:\program files\microsoft visual studio 10.0\vc\include\yvals.h(576) : see declaration of 'char16_t'
"Chee Pin " <cpcheam@gmail.com> wrote in message <hs9gt9$cn1$1@fred.mathworks.com>...
> Hi,
>
> I am trying to compile C dll deployment matlab code with vs2010 and i run into the error below:
>
> error C2371: 'char16_t' : redefinition; different basic types
>
> May I know if there is a way to avoid this. I am using MCR 7.11
>
> Thank you.
|
|
0
|
|
|
|
Reply
|
Venn
|
7/15/2010 1:07:05 PM
|
|
Hello,
I figured out how to get rid of the problem by using namespaces.
I placed #include <matrix.h> inside its own namespace as below:
namespace mat {
#include <matrix.h>
}
"Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i1n15p$2uc$1@fred.mathworks.com>...
> Hello,
>
> I have the same problem too. I am using VS2010 with MATLAB 2008b. Here is the exact error message:
> c:\program files\matlab\r2008b\extern\include\matrix.h(346): error C2371: 'char16_t' : redefinition; different basic types
> c:\program files\microsoft visual studio 10.0\vc\include\yvals.h(576) : see declaration of 'char16_t'
>
>
> "Chee Pin " <cpcheam@gmail.com> wrote in message <hs9gt9$cn1$1@fred.mathworks.com>...
> > Hi,
> >
> > I am trying to compile C dll deployment matlab code with vs2010 and i run into the error below:
> >
> > error C2371: 'char16_t' : redefinition; different basic types
> >
> > May I know if there is a way to avoid this. I am using MCR 7.11
> >
> > Thank you.
|
|
0
|
|
|
|
Reply
|
Venn
|
7/15/2010 1:13:03 PM
|
|
Are you able to make the code to work? I am running into mxCreateString returning NULL all the time...
Chee Pin
|
|
0
|
|
|
|
Reply
|
Chee
|
7/20/2010 2:17:04 AM
|
|
Hi,
Did you add the
namespace mat {
#include <matrix.h>
}
to the start of both the header file and source file? I am getting the exact same error trying to compile an example for using c++ to work with matlab (opencv example). Could you show me your actual code? I am very new to c++ so any help would be much appreciated.
Leo
"Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i1n1gv$osu$1@fred.mathworks.com>...
> Hello,
>
> I figured out how to get rid of the problem by using namespaces.
>
> I placed #include <matrix.h> inside its own namespace as below:
>
> namespace mat {
> #include <matrix.h>
> }
>
>
>
> "Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i1n15p$2uc$1@fred.mathworks.com>...
> > Hello,
> >
> > I have the same problem too. I am using VS2010 with MATLAB 2008b. Here is the exact error message:
> > c:\program files\matlab\r2008b\extern\include\matrix.h(346): error C2371: 'char16_t' : redefinition; different basic types
> > c:\program files\microsoft visual studio 10.0\vc\include\yvals.h(576) : see declaration of 'char16_t'
> >
> >
> > "Chee Pin " <cpcheam@gmail.com> wrote in message <hs9gt9$cn1$1@fred.mathworks.com>...
> > > Hi,
> > >
> > > I am trying to compile C dll deployment matlab code with vs2010 and i run into the error below:
> > >
> > > error C2371: 'char16_t' : redefinition; different basic types
> > >
> > > May I know if there is a way to avoid this. I am using MCR 7.11
> > >
> > > Thank you.
|
|
0
|
|
|
|
Reply
|
lvsteenson (2)
|
7/27/2010 10:33:04 AM
|
|
"Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i1n15p$2uc$1@fred.mathworks.com>...
> Hello,
>
> I have the same problem too. I am using VS2010 with MATLAB 2008b. Here is the exact error message:
> c:\program files\matlab\r2008b\extern\include\matrix.h(346): error C2371: 'char16_t' : redefinition; different basic types
> c:\program files\microsoft visual studio 10.0\vc\include\yvals.h(576) : see declaration of 'char16_t'
Very, Very simple.
Go to line 346 of
c:\program files\matlab\r2008b\extern\include\matrix.h
and change it with what you have in line 576 of
c:\program files\microsoft visual studio 10.0\vc\include\yvals.h
Than everything will work fine.
|
|
0
|
|
|
|
Reply
|
btw.fyi (27)
|
7/27/2010 1:12:05 PM
|
|
The reason you are getting a conflict is because, as Fifo found out, the matrix.h redefines the function that is in yvals.h.
What Fifo suggests is one way to do it.
However, I always hesitate to edit the .h files provide by someone else. Simply put, you could end up destroying the interface functionality they are providing you and therefore not a good programming practice.
Instead, my encapsulating the matrix.h into its own namespace you avoid conflict:
namespace mat {
#include <matrix.h>
}
What this means is that you will have to address the variables/functions within matrix.h by adding the "mat::" prefix to them. For instance, instead of being able to call
mxArray x;
you will have to use
mat::mxArray x;
where "mat" is the namespace within which you included "matrix.h"
Cheers,
-Venn
|
|
0
|
|
|
|
Reply
|
Venn
|
7/27/2010 5:56:26 PM
|
|
Since I didn't find a usable answer here is my solution which works with the Visual Studio 10 C compiler:
#include <yvals.h>
#if (_MSC_VER >= 1600)
#define __STDC_UTF_16__
#endif
#include "mex.h"
It is necessary to include the yvals.h before mex.h (guess matrix.h is the same, because the redefinition code is in matrix.h).
|
|
0
|
|
|
|
Reply
|
Alex
|
7/30/2010 9:32:10 AM
|
|
I also have the same problem. I include the mex.h file, which includes the matrix.h file. Otherwise, I might try the namespace approach. Has anyone at Matlab been contacted about this issue?
|
|
0
|
|
|
|
Reply
|
Robert
|
9/24/2010 5:20:22 PM
|
|
The namespace one works for me. Let me know if I can help.
-Venn
"Alex Höck" <hoeck@eigenart.net> wrote in message <i2u66q$2is$1@fred.mathworks.com>...
> Since I didn't find a usable answer here is my solution which works with the Visual Studio 10 C compiler:
>
> #include <yvals.h>
> #if (_MSC_VER >= 1600)
> #define __STDC_UTF_16__
> #endif
> #include "mex.h"
>
> It is necessary to include the yvals.h before mex.h (guess matrix.h is the same, because the redefinition code is in matrix.h).
|
|
0
|
|
|
|
Reply
|
Venn
|
10/2/2010 6:05:07 PM
|
|
I am trying to do pretty much the same thing. However, i am fairly new to C++ and have never really used namespaces. Where do i have to place:
namespace mat{
#include "matrix.h"
}
At the beginning of the file containing my main{}?
In mat.h? (replacing the " #include "matrix.h" ").
In both? It does not seem to work when modifying only my main{}.
JL
"Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i87s8i$h47$1@fred.mathworks.com>...
> The namespace one works for me. Let me know if I can help.
> -Venn
>
> "Alex Höck" <hoeck@eigenart.net> wrote in message <i2u66q$2is$1@fred.mathworks.com>...
> > Since I didn't find a usable answer here is my solution which works with the Visual Studio 10 C compiler:
> >
> > #include <yvals.h>
> > #if (_MSC_VER >= 1600)
> > #define __STDC_UTF_16__
> > #endif
> > #include "mex.h"
> >
> > It is necessary to include the yvals.h before mex.h (guess matrix.h is the same, because the redefinition code is in matrix.h).
|
|
0
|
|
|
|
Reply
|
José
|
10/5/2010 12:07:06 PM
|
|
Answering my own question:
The file to modify is mat.h, but you also need to add:
using namespace mat;
in the same file. Should work smoothly, i.e. assuming you have administrator rights on your machine.
I am wondering if this will lead to unwanted behavior further on (i am telling myself that no, but we will see).
|
|
0
|
|
|
|
Reply
|
José
|
10/5/2010 12:33:27 PM
|
|
A quick solution is to put the following in your code just before you include the matlab header files:
#ifdef _CHAR16T
#define CHAR16_T
#endif
"Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i1n15p$2uc$1@fred.mathworks.com>...
> Hello,
>
> I have the same problem too. I am using VS2010 with MATLAB 2008b. Here is the exact error message:
> c:\program files\matlab\r2008b\extern\include\matrix.h(346): error C2371: 'char16_t' : redefinition; different basic types
> c:\program files\microsoft visual studio 10.0\vc\include\yvals.h(576) : see declaration of 'char16_t'
>
>
> "Chee Pin " <cpcheam@gmail.com> wrote in message <hs9gt9$cn1$1@fred.mathworks.com>...
> > Hi,
> >
> > I am trying to compile C dll deployment matlab code with vs2010 and i run into the error below:
> >
> > error C2371: 'char16_t' : redefinition; different basic types
> >
> > May I know if there is a way to avoid this. I am using MCR 7.11
> >
> > Thank you.
|
|
0
|
|
|
|
Reply
|
Sander
|
12/17/2010 1:45:29 PM
|
|
This fix,
#ifdef _CHAR16T
#define CHAR16_T
#endif
worked fine for me, but only if I moved the MEX header (mex.h) at the bottom of all includes in my C file.
This didn't work:
#ifdef _CHAR16T
#define CHAR16_T
#endif
#include "mex.h"
#include "cv.h"
but this worked fine:
#include "cv.h"
#ifdef _CHAR16T
#define CHAR16_T
#endif
#include "mex.h"
Zdenek
|
|
0
|
|
|
|
Reply
|
Zdenek
|
12/19/2010 6:40:07 PM
|
|
I tried this namespace method, it doesn't work for me so far. My configuration
MSVS 2010
Matlab 2009Rb
First of all, I'm trying to get the my simple matlab .m file into a .dll file. I finished the wrapper function and in the phase of C++ compiling. However, I couldn't pass the Build so far because of the issue under this thread.
I tried the namespace method by replacing the mat.h file #include "matrix.h" with namespace mat { #include <matrix.h> }
using namespace mat;
It didn't work out for me, I still get the same error. I really don't know where to put the namespace for my project. Can I have your email so that I can enclose my snapshots and my code to you.
"Leo Steenson" <lvsteenson@yahoo.co.uk> wrote in message <i2mcl0$gd5$1@fred.mathworks.com>...
> Hi,
>
> Did you add the
>
> namespace mat {
> #include <matrix.h>
> }
>
> to the start of both the header file and source file? I am getting the exact same error trying to compile an example for using c++ to work with matlab (opencv example). Could you show me your actual code? I am very new to c++ so any help would be much appreciated.
>
> Leo
>
>
>
> "Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i1n1gv$osu$1@fred.mathworks.com>...
> > Hello,
> >
> > I figured out how to get rid of the problem by using namespaces.
> >
> > I placed #include <matrix.h> inside its own namespace as below:
> >
> > namespace mat {
> > #include <matrix.h>
> > }
> >
> >
> >
> > "Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i1n15p$2uc$1@fred.mathworks.com>...
> > > Hello,
> > >
> > > I have the same problem too. I am using VS2010 with MATLAB 2008b. Here is the exact error message:
> > > c:\program files\matlab\r2008b\extern\include\matrix.h(346): error C2371: 'char16_t' : redefinition; different basic types
> > > c:\program files\microsoft visual studio 10.0\vc\include\yvals.h(576) : see declaration of 'char16_t'
> > >
> > >
> > > "Chee Pin " <cpcheam@gmail.com> wrote in message <hs9gt9$cn1$1@fred.mathworks.com>...
> > > > Hi,
> > > >
> > > > I am trying to compile C dll deployment matlab code with vs2010 and i run into the error below:
> > > >
> > > > error C2371: 'char16_t' : redefinition; different basic types
> > > >
> > > > May I know if there is a way to avoid this. I am using MCR 7.11
> > > >
> > > > Thank you.
|
|
0
|
|
|
|
Reply
|
Arnold
|
1/19/2011 6:19:04 PM
|
|
Considering my problem, I'd like to use this namespsace, but I really dont know where to put them. If you take a look at my project, by following your guide, I don't directly include "matrix.h", I think the file "mclmcr.h" include the "matrix.h" I tried to only use this namespace method in matrix.h, but I still got the same problem when I build the whole project. Do you know where to put this namespace in terms of my matrixadd project?
"José-Luis Guerrero" wrote in message <i8f5un$b59$1@fred.mathworks.com>...
> Answering my own question:
> The file to modify is mat.h, but you also need to add:
> using namespace mat;
> in the same file. Should work smoothly, i.e. assuming you have administrator rights on your machine.
> I am wondering if this will lead to unwanted behavior further on (i am telling myself that no, but we will see).
|
|
0
|
|
|
|
Reply
|
Arnold
|
1/19/2011 9:09:05 PM
|
|
Considering my problem, I'd like to use this namespsace, but I really dont know where to put them. If you take a look at my project, by following your guide, I don't directly include "matrix.h", I think the file "mclmcr.h" include the "matrix.h" I tried to only use this namespace method in matrix.h, but I still got the same problem when I build the whole project. Do you know where to put this namespace in terms of my matrixadd project?
"José-Luis Guerrero" wrote in message <i8f5un$b59$1@fred.mathworks.com>...
> Answering my own question:
> The file to modify is mat.h, but you also need to add:
> using namespace mat;
> in the same file. Should work smoothly, i.e. assuming you have administrator rights on your machine.
> I am wondering if this will lead to unwanted behavior further on (i am telling myself that no, but we will see).
|
|
0
|
|
|
|
Reply
|
Arnold
|
1/19/2011 9:10:05 PM
|
|
@Venn,
I just hit the same problem than while compiling for Matlab.
In which file do you make this change? My yvals.h does not have a line cointaining
#include <matrix.h>
Thanks
Simon
"Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i1n1gv$osu$1@fred.mathworks.com>...
> Hello,
>
> I figured out how to get rid of the problem by using namespaces.
>
> I placed #include <matrix.h> inside its own namespace as below:
>
> namespace mat {
> #include <matrix.h>
> }
>
>
>
> "Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i1n15p$2uc$1@fred.mathworks.com>...
> > Hello,
> >
> > I have the same problem too. I am using VS2010 with MATLAB 2008b. Here is the exact error message:
> > c:\program files\matlab\r2008b\extern\include\matrix.h(346): error C2371: 'char16_t' : redefinition; different basic types
> > c:\program files\microsoft visual studio 10.0\vc\include\yvals.h(576) : see declaration of 'char16_t'
> >
> >
> > "Chee Pin " <cpcheam@gmail.com> wrote in message <hs9gt9$cn1$1@fred.mathworks.com>...
> > > Hi,
> > >
> > > I am trying to compile C dll deployment matlab code with vs2010 and i run into the error below:
> > >
> > > error C2371: 'char16_t' : redefinition; different basic types
> > >
> > > May I know if there is a way to avoid this. I am using MCR 7.11
> > >
> > > Thank you.
|
|
0
|
|
|
|
Reply
|
svfilhol (2)
|
6/22/2011 1:10:20 AM
|
|
@ Simon,
Not in yvals.h... it should be in your own source code.
Let us say you have two files with the same name. To store them both, you could put them in two separate folders. Later, when you access them, you specify the paths to their specific locations.
Similarly, if you are including any of the matlab provided headers in your code, I'd put them in a separate namespace, say conveniently named "mat". This way any of the matlab provided functions don't conflict with those that might already exist (say, via including windows.h). Now, if you want to call the functions inside those matlab headers, you will have to specify the namespace by prefixing the functions with "mat::" to specify their 'path'.
Regards,
-Venn
"Simon " <svfilhol@alaska.edu> wrote in message <itrfds$pdm$1@newscl01ah.mathworks.com>...
> @Venn,
> I just hit the same problem than while compiling for Matlab.
> In which file do you make this change? My yvals.h does not have a line cointaining
> #include <matrix.h>
> Thanks
> Simon
>
>
>
> "Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i1n1gv$osu$1@fred.mathworks.com>...
> > Hello,
> >
> > I figured out how to get rid of the problem by using namespaces.
> >
> > I placed #include <matrix.h> inside its own namespace as below:
> >
> > namespace mat {
> > #include <matrix.h>
> > }
> >
> >
> >
> > "Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i1n15p$2uc$1@fred.mathworks.com>...
> > > Hello,
> > >
> > > I have the same problem too. I am using VS2010 with MATLAB 2008b. Here is the exact error message:
> > > c:\program files\matlab\r2008b\extern\include\matrix.h(346): error C2371: 'char16_t' : redefinition; different basic types
> > > c:\program files\microsoft visual studio 10.0\vc\include\yvals.h(576) : see declaration of 'char16_t'
> > >
> > >
> > > "Chee Pin " <cpcheam@gmail.com> wrote in message <hs9gt9$cn1$1@fred.mathworks.com>...
> > > > Hi,
> > > >
> > > > I am trying to compile C dll deployment matlab code with vs2010 and i run into the error below:
> > > >
> > > > error C2371: 'char16_t' : redefinition; different basic types
> > > >
> > > > May I know if there is a way to avoid this. I am using MCR 7.11
> > > >
> > > > Thank you.
|
|
0
|
|
|
|
Reply
|
Venn
|
6/22/2011 6:26:05 PM
|
|
Venn,
What do you mean by my own source code? mex.h?
Because when i do the change in mex.h, the error disappear, for an entire set of new errors coming from the files "sourceannotations.h" and "stdio.h". It looks like the problem comes from the prefixing mat::.
So have put in front of every function beginning with mx... the prefix mat::
I still end up with this full page of syntax error:
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(244) : error C3083: 'vc_attributes': the symbol to the left of a '::' must be a type
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(244) : error C2039: 'YesNoMaybe' : is not a member of '`global namespace''
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(244) : error C2146: syntax error : missing ';' before identifier 'SA_YesNoMaybe'
c:\program files (x86)\microsoft visual studio 10.0\vc\include\codeanalysis\sourceannotations.h(244) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
....
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\stdio.h(197) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\stdio.h(236) : error C2143: syntax error : missing ';' before '__cdecl'
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\INCLUDE\stdio.h(236) : error C4430: missing type specifier - int assumed. Note: C++ does not support default-int
Simon
"Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <ittc3t$bhc$1@newscl01ah.mathworks.com>...
> @ Simon,
>
> Not in yvals.h... it should be in your own source code.
>
> Let us say you have two files with the same name. To store them both, you could put them in two separate folders. Later, when you access them, you specify the paths to their specific locations.
>
> Similarly, if you are including any of the matlab provided headers in your code, I'd put them in a separate namespace, say conveniently named "mat". This way any of the matlab provided functions don't conflict with those that might already exist (say, via including windows.h). Now, if you want to call the functions inside those matlab headers, you will have to specify the namespace by prefixing the functions with "mat::" to specify their 'path'.
>
> Regards,
> -Venn
>
|
|
0
|
|
|
|
Reply
|
svfilhol (2)
|
6/22/2011 7:52:05 PM
|
|
Thanks Sander, great solution! -- Manu.
"Sander " <niemeijer@stcorp.nl> wrote in message <iefpho$rvh$1@fred.mathworks.com>...
> A quick solution is to put the following in your code just before you include the matlab header files:
>
> #ifdef _CHAR16T
> #define CHAR16_T
> #endif
>
> "Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i1n15p$2uc$1@fred.mathworks.com>...
> > Hello,
> >
> > I have the same problem too. I am using VS2010 with MATLAB 2008b. Here is the exact error message:
> > c:\program files\matlab\r2008b\extern\include\matrix.h(346): error C2371: 'char16_t' : redefinition; different basic types
> > c:\program files\microsoft visual studio 10.0\vc\include\yvals.h(576) : see declaration of 'char16_t'
> >
> >
> > "Chee Pin " <cpcheam@gmail.com> wrote in message <hs9gt9$cn1$1@fred.mathworks.com>...
> > > Hi,
> > >
> > > I am trying to compile C dll deployment matlab code with vs2010 and i run into the error below:
> > >
> > > error C2371: 'char16_t' : redefinition; different basic types
> > >
> > > May I know if there is a way to avoid this. I am using MCR 7.11
> > >
> > > Thank you.
|
|
0
|
|
|
|
Reply
|
sethimanu19 (2)
|
3/9/2012 1:15:12 PM
|
|
All,
I recently ran into this bad problem (that MATLAB and VS2010 definitions clash) in an old project I am resurrecting, and found that MATLAB 2010b libraries / headers have resolved this issue.
Thought I should add that to this thread for any future wanderers through this kind of build error.
-David
"Manu" wrote in message <jjcvp0$rjf$1@newscl01ah.mathworks.com>...
> Thanks Sander, great solution! -- Manu.
> "Sander " <niemeijer@stcorp.nl> wrote in message <iefpho$rvh$1@fred.mathworks.com>...
> > A quick solution is to put the following in your code just before you include the matlab header files:
> >
> > #ifdef _CHAR16T
> > #define CHAR16_T
> > #endif
> >
> > "Venn Ravichandran" <vennjr@u.northwestern.edu> wrote in message <i1n15p$2uc$1@fred.mathworks.com>...
> > > Hello,
> > >
> > > I have the same problem too. I am using VS2010 with MATLAB 2008b. Here is the exact error message:
> > > c:\program files\matlab\r2008b\extern\include\matrix.h(346): error C2371: 'char16_t' : redefinition; different basic types
> > > c:\program files\microsoft visual studio 10.0\vc\include\yvals.h(576) : see declaration of 'char16_t'
> > >
> > >
> > > "Chee Pin " <cpcheam@gmail.com> wrote in message <hs9gt9$cn1$1@fred.mathworks.com>...
> > > > Hi,
> > > >
> > > > I am trying to compile C dll deployment matlab code with vs2010 and i run into the error below:
> > > >
> > > > error C2371: 'char16_t' : redefinition; different basic types
> > > >
> > > > May I know if there is a way to avoid this. I am using MCR 7.11
> > > >
> > > > Thank you.
|
|
0
|
|
|
|
Reply
|
dgross (1)
|
2/28/2013 8:11:07 PM
|
|
"Chee Pin" wrote in message <hs9gt9$cn1$1@fred.mathworks.com>...
> Hi,
>
> I am trying to compile C dll deployment matlab code with vs2010 and i run into the error below:
>
> error C2371: 'char16_t' : redefinition; different basic types
>
> May I know if there is a way to avoid this. I am using MCR 7.11
>
> Thank you.
Project Setting > C/C++ > Language > ... wchart_t --> No (/Zc:wchar_t-)
|
|
0
|
|
|
|
Reply
|
sdongik (1)
|
3/18/2013 12:57:10 AM
|
|
|
22 Replies
945 Views
(page loaded in 0.318 seconds)
|