gpt4 book ai didi

c++ - 编译C dll部署MATLAB代码时出现错误C2371

转载 作者:行者123 更新时间:2023-12-02 11:04:01 25 4
gpt4 key购买 nike

我试图使用带有MATLAB 2007b的VS2010编译C dll。我收到此错误:

c:\program files\microsoft visual studio 10.0\vc\include\yvals.h(576): error C2371: 'char16_t' : redefinition; different basic types
c:\program files\matlab\r2007b\extern\include\matrix.h(336) : see declaration of 'char16_t'

这是代码:

#include <FLOAT.H>
#include <stdlib.h>
#include <stdio.h>
#include <malloc.h>
#include "..\OpenCV_Lib.h"
//namespace mat{
#include "..\MATCVcomm.h"
//}
//#include "matrix.h"

//using namespace mat;

#define Out plhs[0]
#define Outlist plhs[1]
#define Ref prhs[0]
#define Para prhs[1]
#define IMAGE_NUM prhs[2]
/*
Out:Cell Array m by n
m:size of input array m
n:number of member include the groupe + 1
first member of each cell if indicate n
ref:Input array
para:parametor of grouping shown below
[r num]
r:radius of groupe
num:The number of groups extracted by this function
(in case by that there are a great many groups)
IMAGE_NUM:Image Index List
*/
#include "groupe.h"


void mexFunction(
int nlhs, mxArray *plhs[],
int nrhs, const mxArray *prhs[]
)
{
double min = DBL_MAX;
int i, j;
if( nrhs < 2 ){
mexErrMsgTxt("groupe function requirs two input parametor for Matrix of point and [rad num]");
return;
}
int param = mxGetM( Para );
int Rn = mxGetN( Ref );
int Rm = mxGetM( Ref );

double * para = mxGetPr( Para );
double * pref = mxGetPr( Ref );
double rad = para[0];
int gnum;
if( param > 1 )
gnum = (int)(para[1]);
else
gnum = 0;

class memlist mem = groupe( pref, Rm, Rn, rad );
if( nrhs >= 3 ){
int imnn = mxGetM( IMAGE_NUM );
if( imnn != Rm ){
mexErrMsgTxt("Need that Number of ImageIndexList equal Number of KeyList.");
return;
}
double * dimno = mxGetPr( IMAGE_NUM );
int * imno = new int[imnn];
for( i = 0; i < imnn; i ++ )
imno[i] = (int)dimno[i];
LookBigOrder( mem, imno, pref, Rm, Rn );
}
class memlist mem2 = LookBigOrder( mem, gnum );
Rm = mem2.GetEntrysize()-1;
if( nlhs >= 2 ){
Outlist = mxCreateDoubleMatrix( Rm, 2, mxREAL );
double * l = mxGetPr( Outlist );
for( i = 0; i < Rm; i ++ )
l[i] = mem2.GetSize( i );
for( i = 0; i < Rm; i ++ )
l[i+Rm] = mem2.GetIndex(mem2.GetSize( Rm ))[i];
}
Out = mxCreateCellMatrix( Rm, 1 );
for( i = 0; i < Rm; i ++ ){
mxArray * r = mxCreateDoubleMatrix( 1, mem2.GetSize( i ), mxREAL );
double * l = mxGetPr( r );
for( j = 0; j < mem2.GetSize( i ); j ++ )
l[j] = mem2.GetIndex(i)[j];
mxSetCell( Out, i, r );
}
mem.free();
mem2.free();
}

在寻找解决方案时,我尝试了几种方法,但还没有找到解决此问题的方法。

我该如何解决?

谢谢!

最佳答案

可能char16_t由Matlab和C++标准库同时定义。

当包含C库时,代替
#include <stdlib.h>
采用
#include <cstdlib>
代替。即删除.h并在前面放一个c。

这应该将其内容放入std命名空间中,以便您选择所需的内容。

关于c++ - 编译C dll部署MATLAB代码时出现错误C2371,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24729045/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com