Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/150.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 从c+调用matlabdll+;:无法初始化库_C++_Visual Studio 2010_Matlab_Sift_Matlab Compiler - Fatal编程技术网

C++ 从c+调用matlabdll+;:无法初始化库

C++ 从c+调用matlabdll+;:无法初始化库,c++,visual-studio-2010,matlab,sift,matlab-compiler,C++,Visual Studio 2010,Matlab,Sift,Matlab Compiler,我尝试使用演示代码来检测和匹配David Lowe的SIFT特性(lowe@cs.ubc.ca) 在我的代码中。因此,我在Matlab中编译(.m)文件以生成DLL。以下是Matlab中的命令代码: mcc -B csharedlib:SiftMatch match.m sift.m -v 但是,当我在C++代码中使用DLL(在VS2010下)时,存在一个问题: SiftMatchInitialize(); This function r

我尝试使用演示代码来检测和匹配David Lowe的SIFT特性(lowe@cs.ubc.ca)

在我的代码中。因此,我在Matlab中编译(.m)文件以生成DLL。以下是Matlab中的命令代码:

           mcc -B csharedlib:SiftMatch match.m sift.m -v

但是,当我在C++代码中使用DLL(在VS2010下)时,存在一个问题:

              SiftMatchInitialize();
   This function returned false. I could not initialize the library.
调试结果表明:

    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;
}
在这个函数中,ctfStream为NULL,bResult等于0。
那么,问题出在哪里呢?

不要将MATLAB编译器生成的.c/.cpp文件包含到项目中。只需要头文件和.lib文件。

您可以尝试相同的方法,但使用默认的共享库项目(即仅使用ass sift.m,不更改任何参数),而不是直接调用mcc吗?如果可以,将项目输出与您的mcc行进行比较:线索将出现在不同的选项中。谢谢。我尝试使用项目界面。我发现生成时.m文件中有一些错误。所以这就是为什么初始化失败的原因。@幸运的是,如果你使用C++,为什么不使用OpenCV?它有SIFT实现吗?