gpt4 book ai didi

c - 错误LNK2001 : unresolved external symbol mexFunction

转载 作者:行者123 更新时间:2023-11-30 15:34:05 34 4
gpt4 key购买 nike

我正在尝试为简单的 C 函数创建 MEX 文件,如下所示:

#include <math.h>
#include <mex.h>

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
int main()
{
int x;
int c;
c=2;
x=4;
mexprintf ("the value for y is %d",c*x*x);

}

我将文件保存为quad.c但是在Matlab上,当我使用mex函数时

 mex quad.c

我收到错误:

 >> mex quadfinal.c
LINK : error LNK2001: unresolved external symbol mexFunction
C:\Users\Oatmeel\AppData\Local\Temp\mex_UGPnwF\templib.x : fatal error LNK1120: 1 unresolved externals

C:\PROGRA~1\MATLAB\R2013A\BIN\MEX.PL: Error: Link of 'quadfinal.mexw64' failed.

Error using mex (line 206)
Unable to complete successfully.

我正确地包含了 mexFunction。我不知道我哪里错了。请帮忙!

最佳答案

替换这个:

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[]);
int main()

通过这个:

void mexFunction(int nlhs, mxArray *plhs[], int nrhs, const mxArray *prhs[])

请注意,末尾没有 ;

编辑:此外,mexprintf 应该是 mexPrintf

关于c - 错误LNK2001 : unresolved external symbol mexFunction,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23439764/

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