0

VS2012 または VS2013、Intel コンパイラを使用する C++ プログラムから、matlab 2014a、Win7 64 ビット、64 ビット ビルドを使用して Matlab エンジンを起動できません。Matlab 2013a を使用してエンジンを正常に始動できます。2014a にリンクすると、プログラムは libmwmfl_scalar.dll が見つからず、起動しないと不平を言います。これは 2013 に含まれていた dll ですが、2014a には含まれていないようです (プログラムまたはコンパイラ ランタイム ディストリビューションのいずれかに)。2013a にリンクしても問題ありません。2014a に更新すると、古い DLL を要求するのはなぜですか? すべてのインクルード、ライブラリ、環境を 2014a に変更し、クリーン後に再構築しました。プロパティで libmwmfl_scalar.dll への明示的な参照がなく、すべてのフォルダーを 2014a に変更しました。Matlab を使用する他のものにはリンクしていません。この dll は '

設定は、関連するコンテキストを提供する別の投稿 ( Visual Studio で MATLAB を直接呼び出す (マルチスレッド) ) のこのプロパティ シートと同じです。

<?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:\PROGRA~2 \Intel\MPI\411~1.036\em64t\bin;C:\PROGRA~2\Intel\COMPOS~1\bin\intel64;C:\PROGRA~2\Intel\COMPOS~1\redist\intel64\compiler;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:\Program Files ( x86)\Microsoft ASP.NET\ASP.NET Web Pages\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:\ghc-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\\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\\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 にリンクすると、プログラムが実行されることを確認しました。libmwmfl_scalar.dll がないために実行されないのは、デバッグ目的 (「デバッグ/デバッグ開始」または「デバッグ/デバッグなしで開始」) で VS から実行しようとしたときです。そのため、何らかの理由で、プログラム自体が使用していないときにVSがプログラムを実行することを主張しています。

4

0 に答える 0