无法在 C++ 中初始化 Matlab dll
Unable initialize the Matlab dll in c++
我正在使用 Windows 7 x64 与 Matlab R2012b x32 和 VS2010。
我想在 C++ 中调用名为 add
的 Matlab 函数。所以我使用 mcc
命令将 add.m
转换为 dll,并将其添加到我的项目中。但是我尝试初始化dll后出现错误。
int _tmain(int argc, _TCHAR* argv[])
{
if(!addInitialize())
cout<<"addInitialize fail!!!"<<endl;
return 0;
}
输出信息:
First-chance exception at 0x74c6c42d in MatlabTest.exe: Microsoft C++ exception: MathWorks::mcli18nutil::DeployedException at memory location 0x0029eff0..
The thread 'Win32 Thread' (0xc04) has exited with code 0 (0x0).
The program '[1100] MatlabTest.exe: Native' has exited with code 0 (0x0).
因为我运行 mcc
命令带有-C
选项,所以我需要在初始化dll之前将add.ctf
文件添加到dll所在的路径。
我也可以在没有 -C
选项的情况下再次 运行 mcc
命令来生成新的 dll。并使用新的dll代替旧的来解决这个问题。
我正在使用 Windows 7 x64 与 Matlab R2012b x32 和 VS2010。
我想在 C++ 中调用名为 add
的 Matlab 函数。所以我使用 mcc
命令将 add.m
转换为 dll,并将其添加到我的项目中。但是我尝试初始化dll后出现错误。
int _tmain(int argc, _TCHAR* argv[])
{
if(!addInitialize())
cout<<"addInitialize fail!!!"<<endl;
return 0;
}
输出信息:
First-chance exception at 0x74c6c42d in MatlabTest.exe: Microsoft C++ exception: MathWorks::mcli18nutil::DeployedException at memory location 0x0029eff0..
The thread 'Win32 Thread' (0xc04) has exited with code 0 (0x0).
The program '[1100] MatlabTest.exe: Native' has exited with code 0 (0x0).
因为我运行 mcc
命令带有-C
选项,所以我需要在初始化dll之前将add.ctf
文件添加到dll所在的路径。
我也可以在没有 -C
选项的情况下再次 运行 mcc
命令来生成新的 dll。并使用新的dll代替旧的来解决这个问题。