从 .c 创建 DLL 文件
Posted
技术标签:
【中文标题】从 .c 创建 DLL 文件【英文标题】:Create DLL file from .c 【发布时间】:2015-10-13 13:56:00 【问题描述】:我正在尝试从这个 .c 代码(用于 Labview)创建一个 .dll 文件。 http://www.mathworks.com/matlabcentral/fileexchange/26190-vchoosek
但我无法编译它,也无法使用 VisualStudio 或“mcc”,因为两个编译器都返回此错误:
VChooseK.obj : error LNK2019: unresolved external symbol mexErrMsgIdAndTxt referenced in function BadInputTypeError
VChooseK.obj : error LNK2019: unresolved external symbol mxFree referenced in function ElemK_8Byte
VChooseK.obj : error LNK2019: unresolved external symbol mxMalloc referenced in function ElemK_8Byte
VChooseK.obj : error LNK2019: unresolved external symbol mxGetData referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxGetPr referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxGetElementSize referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mexWarnMsgIdAndTxt referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxCreateNumericMatrix_730 referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxGetClassID referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxSetN_730 referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxSetM_730 referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxDuplicateArray referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxGetScalar referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxGetNumberOfElements referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxIsDouble referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxIsLogical referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxIsChar referenced in function mexFunction
VChooseK.obj : error LNK2019: unresolved external symbol mxIsNumeric referenced in function mexFunction
有人可以帮助我吗? 我已经在 VisualStudio 中包含了“mex.h”的路径
【问题讨论】:
【参考方案1】:您必须包含重要的链接库。如果需要,可以使用 libmex.lib;libmat.lib;libmx.lib 等库。 如果您使用的是 MATLAB 2018b,则包含路径必须包含“C:\Program Files\MATLAB\R2018b\extern\include”和库路径“C:\Program Files\MATLAB\R2018b\extern\lib\win64\microsoft” .
【讨论】:
以上是关于从 .c 创建 DLL 文件的主要内容,如果未能解决你的问题,请参考以下文章