Matlab引擎2014a将无法在Windows 7 64位下启动 - 缺少2013a dll

时间:2014-10-11 00:00:07

标签: c++ matlab visual-studio matlab-engine

我无法使用matlab 2014a,Win7 64bit,使用VS2012或VS2013,英特尔编译器的c ++程序构建64位。我可以使用Matlab 2013a启动引擎。如果我链接到2014a该程序抱怨libmwmfl_scalar.dll丢失,将无法启动。这是一个包含在2013中的dll,但似乎不再包含在2014a中(无论是在程序中还是在编译器运行时分发中)。如果我链接到2013a它没有遇到任何问题。当我更新到2014a时,为什么它会坚持使用旧的DLL?我已将所有包含,库,环境更改为2014a并在清理后重建。我没有在我的属性中明确引用libmwmfl_scalar.dll并将所有文件夹更改为2014a。我没有链接到任何使用Matlab的东西。如果我在链接的可执行文件上运行依赖walker,则不会显示此dll。

设置与此属性表中的另一个帖子(Call MATLAB directly (multiple threading) in Visual Studio)相同,后者提供了一些相关的上下文。

<?xml version="1.0" encoding="utf-8"?>
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
  <ImportGroup Label="PropertySheets" />
  <PropertyGroup Label="UserMacros" />
  <PropertyGroup>
    <LocalDebuggerEnvironment>PATH=C:\Program Files\MATLAB\R2014a\bin\win64;%PATH%$(LocalDebuggerEnvironment)</LocalDebuggerEnvironment>
  </PropertyGroup>
  <ItemDefinitionGroup>
    <ClCompile>
      <AdditionalIncludeDirectories>C:\Program Files\MATLAB\R2014a\extern\include;C:\Program Files\MATLAB\R2014a\extern\include\win64</AdditionalIncludeDirectories>
      <PreprocessorDefinitions>IBMPC</PreprocessorDefinitions>
    </ClCompile>
    <Link>
      <AdditionalLibraryDirectories>C:\Program Files\MATLAB\R2014a\extern\lib\win64\microsoft</AdditionalLibraryDirectories>
      <AdditionalDependencies>libmx.lib;libmex.lib;libmat.lib;libeng.lib;mclmcrrt.lib</AdditionalDependencies>
    </Link>
  </ItemDefinitionGroup>
  <ItemGroup />
</Project>

Ben - 不,我没有使用Mex文件。这是调用Matlab的代码

void mlsurfaceplot(std::vector<std::vector<double>> surface,std::vector<double> Xdat,std::vector<double> Ydat)

{
    Engine *ep;
    mxArray *Xmx = NULL, *result = NULL;
    mxArray *Ymx=NULL;
    mxArray *Zmx=NULL;
    char buffer[BUFSIZE+1];
    //  double tim[10] = { 0.0, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0 };
    //Have to stick vectors in arrays for Matlab xfer
    double *xArray;                //Declare pointer to type of array
    xArray = new double[Xdat.size()];   //use 'new' to create array of size x
    double *yArray;                //Declare pointer to type of array
    yArray = new double[Ydat.size()];   //use 'new' to create array of size x
    double *zArray;                //Declare pointer to type of array
    zArray = new double[Xdat.size()*Ydat.size()];   //use 'new' to create array of size x

for (int j = 0; j < Xdat.size(); j++)
{
    xArray[j]=Xdat[j];
}

for (int j = 0; j < Ydat.size(); j++)
{
    yArray[j]=Ydat[j];
}

for (int i = 0; i < Xdat.size(); i++)
{
    for (int j = 0; j < Ydat.size(); j++)
    {
        zArray[i+Xdat.size()*j]=surface[i][j];
    }

}


/*
* Call engOpen with a NULL string. This starts a MATLAB process 
* on the current host using the command "matlab".
*/
if (!(ep = engOpen(""))) {
    fprintf(stderr, "\nCan't start MATLAB engine\n");
    //return EXIT_FAILURE;
}


/* 
* Create a variable for our data
*/
using namespace std;
Xmx  = mxCreateDoubleMatrix(1,Xdat.size(), mxREAL);
Ymx  = mxCreateDoubleMatrix(1,Ydat.size(), mxREAL);
Zmx  = mxCreateDoubleMatrix(Xdat.size(), Ydat.size(), mxREAL);
//T = mxCreateDoubleMatrix(3, 2, mxREAL);
//memcpy((void *)mxGetPr(T), (void *)tim, sizeof(tim));
memcpy(mxGetPr(Xmx), &xArray[0], sizeof(double)*Xdat.size());
memcpy(mxGetPr(Ymx), &yArray[0], sizeof(double)*Ydat.size());
memcpy(mxGetPr(Zmx), &zArray[0], sizeof(double)*Xdat.size()*Ydat.size());

//std::cout<<T[0]<<std::endl;
/*
* Place the variable T into the MATLAB workspace
*/
engPutVariable(ep, "X", Xmx);   engPutVariable(ep, "Y", Ymx);
engPutVariable(ep, "Z", Zmx);

std::cout<<*mxGetPr(Xmx)<<std::endl;
std::cout<<*mxGetPr(Ymx)<<std::endl;
std::cout<<*mxGetPr(Zmx)<<std::endl;
std::cout<<*(mxGetPr(Xmx)+1)<<std::endl;
std::cout<<*(mxGetPr(Ymx)+1)<<std::endl;
std::cout<<*(mxGetPr(Zmx)+1)<<std::endl;


/*
* Plot the result
*/

engEvalString(ep, "surf(X,Y,Z')");
engEvalString(ep, "ylabel('Log Spot/Strike')");
engEvalString(ep, "xlabel('Expiry (Years)')");
engEvalString(ep, "zlabel('Black 76 Vol')");

engEvalString(ep, "alpha(0.5)");
engEvalString(ep,"saveas(figure1,'c:\\users\\Rodney\\Documents\\filename2.jpg'),'jpg'");


/*
* use fgetc() to make sure that we pause long enough to be
* able to see the plot
*/

printf("Hit return to continue\n\n");
fgetc(stdin);
int jj;
cin>>jj;
/*
* We're done for Part I! Free memory, close MATLAB figure.
*/
printf("Done for Part I.\n");



mxDestroyArray(Xmx);
mxDestroyArray(Ymx);
mxDestroyArray(Zmx);
//  mxDestroyArray(T);
engEvalString(ep, "close;");





//  return 0;
}

这是我的路径,2013a和2014a都有。我也尝试删除2013a,重新启动VS,重建但它仍然在寻找旧的DLL。

C:\ Program Files(x86)\ Common Files \ Intel \ Shared Libraries \ redist \ intel64 \ mpirt; C:\ Program Files(x86)\ Common Files \ Intel \ Shared Libraries \ redist \ ia32 \ mpirt; C :\ Program Files(x86)\ Common Files \ Intel \ Shared Libraries \ redist \ intel64 \ compiler; C:\ Program Files(x86)\ Common Files \ Intel \ Shared Libraries \ redist \ ia32 \ compiler; C:\ Program Files (x86)\ Intel \ icsxe \ 2013.1.046 \ bin; C:\ Program Files \ MATLAB \ R2014a \ bin; C:\ Program Files \ MATLAB \ R2014a \ bin \ win64; C:\ Users \ Rodney \ Anaconda \ Lib \ site-packages \ PyQt4; C:\ Program Files(x86)\ Intel \ Trace Analyzer and Collector \ 8.1.4.045 \ bin; C:\ Program Files(x86)\ Intel \ MPI \ 4.1.3.045 \ em64t \ bin; C:\ Program Files(x86)\ Intel \ MPI \ 4.1.3.045 \ ia32 \ bin; C:\ Program Files(x86)\ Common Files \ Intel \ Shared Libraries \ redist \ intel64 \ mpirt; C:\ Program Files( x86)\ Common Files \ Intel \ Shared Libraries \ redist \ ia32 \ mpirt; C:\ Program Files(x86)\ Common Files \ Intel \ Shared Libraries \ redist \ intel64 \ compiler; C:\ Program Files(x86)\ Common Files \ Intel \ Shared Libraries \ redist \ ia32 \ compiler; C:\ PR OGRA〜2 \英特尔\ MPI \ 411〜1.036 \ EM64T \ BIN; C:\ PROGRA〜2 \英特尔\ COMPOS〜1 \ BIN \ Intel64位; C:\ PROGRA〜2 \英特尔\ COMPOS〜1 \ REDIST \ Intel64位\编译器; C:\ PROGRA~2 \ MICROS; C:\ Program Files(x86)\ Windows Kits \ 8.1 \ Windows Performance Toolkit \; C:\ Program Files \ Microsoft SQL Server \ 110 \ Tools \ Binn \; C:\程序文件(x86)\ Microsoft ASP.NET \ ASP.NET网页\ v1.0 \; C:\ Program Files(x86)\ Common Files \ Seagate \ SnapAPI \; C:\ Program Files \ MATLAB \ R2014a \ runtime \ win64; C:\ Program Files \ MATLAB \ R2014a \ polyspace \ bin; \ win64; C:\ Program Files \ MATLAB \ MATLAB Compiler Runtime \ v83 \ runtime \ win64; C:\ Program Files \ MATLAB \ R2013a \ runtime \ win64; C:\ Program Files \ MATLAB \ R2013a \ bin; C:\ Program Files \ MATLAB \ R2013a \ bin \ win64; C:\ Users \ Rodney \ Anaconda; C:\ Users \ Rodney \ Anaconda \ Scripts; C: \ PROGRA~2 \ Gambit-C \ v4.7.2 \ bin; C:\ Users \ Rodney \ AppData \ Roaming \ cabal \ bin; C:\ Program Files(x86)\ Intel \ Trace Analyzer and Collector \ 8.1.4.045 \ dll \ impi64; C:\ Program Files(x86)\ Intel \ Trace Analyzer and Collector \ 8.1.3.037 \ dll \ impi64; C:\ Program Files \ smartmontools \ bin; C:\ g hc-7.6.3 \ bin; C:\ Program Files(x86)\ WinAnt \ bin; c:\ windows \ system32; C:\ Users \ Rodney \ AppData \ Roaming \ cabal \ bin \; C:\ Program Files \ MiKTeX 2.9 \ miktex \ bin \ x64 \; C:\ Program Files(x86)\ Microsoft SDKs \ TypeScript \ 1.0 \

更新:我尝试在VS2013中创建一个新的解决方案和项目,它适用于ML2014a。因此它必须是影响我现有项目或解决方案的东西,但由于我没有与Matlab的间接依赖关系并且设置了2014a版本的所有路径,因此很难跟踪。我的程序使用外部库Boost,Intel MKL,Armadillo,Eigen,Quantlib。完全难倒。

更新2: 我已经检查过,我的程序在Visual Studio环境之外与2014a链接时运行。当我尝试从VS运行它以进行调试时(“调试/启动调试”或“调试/启动而不调试”),它因为缺少libmwmfl_scalar.dll而无法运行。因此,出于某种原因,当程序本身不使用它时,VS坚持要运行该程序。

0 个答案:

没有答案