[英]call matlab dll from c++: fail to initialize the library
I try to use Demo code for detecting and matching SIFT features of David Lowe (lowe@cs.ubc.ca) 我尝试使用演示代码来检测和匹配David Lowe的SIFT功能(lowe@cs.ubc.ca)
in my code. 在我的代码中。 So I compile the (.m)file in Matlab to generate DLL.
所以我在Matlab中编译(.m)文件以生成DLL。 Here is the command code in Matlab:
这是Matlab中的命令代码:
mcc -B csharedlib:SiftMatch match.m sift.m -v
However, when I use the DLL in my C++ code( under VS2010), there is a problem: 但是,当我在C ++代码(在VS2010下)中使用DLL时,出现了一个问题:
SiftMatchInitialize();
This function returned false. I could not initialize the library.
and debug showed that: 并且调试显示:
bool MW_CALL_CONV SiftMatchInitializeWithHandlers(
mclOutputHandlerFcn error_handler,
mclOutputHandlerFcn print_handler)
{
int bResult = 0;
if (_mcr_inst != NULL)
return true;
if (!mclmcrInitialize())
return false;
if (!GetModuleFileName(GetModuleHandle("SiftMatch"), path_to_dll, _MAX_PATH))
return false;
{
mclCtfStream ctfStream =
mclGetEmbeddedCtfStream(path_to_dll);
if (ctfStream) {
bResult = mclInitializeComponentInstanceEmbedded( &_mcr_inst,
error_handler,
print_handler,
ctfStream);
mclDestroyStream(ctfStream);
} else {
bResult = 0;
}
}
if (!bResult)
return false;
return true;
}
In this function ctfStream is NULL and bResult equals 0. So, what's the problem? 在此函数中,ctfStream为NULL,bResult等于0。那么,什么问题呢?
Do not include the .c/.cpp files generated by MATLAB Compiler into your project. 不要将由MATLAB Compiler生成的.c / .cpp文件包含到您的项目中。 Only the header file and .lib file is needed.
只需要头文件和.lib文件。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.