engOpen 返回 Null
当我尝试从 C++ 代码调用 Matlab 函数时遇到问题。
当我调用 engOpen 时,它总是返回 NULL。 这是代码:
Engine *m_pEngine;
m_pEngine = engOpen(NULL);
if(m_pEngine == NULL)
{
cout << "Error" << endl;
exit(1);
}
有人知道如何解决这个问题吗?
谢谢 !!!
I'm having a problem when I try to call a Matlab funcion from my C++ code.
When I call engOpen, it always returns NULL.
Here is the code:
Engine *m_pEngine;
m_pEngine = engOpen(NULL);
if(m_pEngine == NULL)
{
cout << "Error" << endl;
exit(1);
}
Does somebody know how to solve this?
Thanks !!!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要以管理员模式启动Matlab
右键单击 Matlab 图标并选择“以管理员身份运行”。
即使您在管理期间注册了 Matlab,也应该检查此项,如果当前未注册为 COM 链接,则它将不支持 engOpen。
engOpen("") 也应该可以工作
这并不是全部,您必须记住 IDE 配置(或链接器)的某些 mods,如果您使用命令行,则包含选项编译器)。
这是一个解决这些问题的 Matlab 管理页面。超越 COM 链接问题。
https://www.mathworks.com/matlabcentral/answers/100603-how-can-i-compile-a-matlab-engine-application-using-microsoft-visual-studio-9-0-or-10 -0
you need to launch Matlab in administrator mode
right-click on the Matlab icon and select "run as administrator"
You should check this even if you have registered Matlab during admin, if it is not currently registered as the COM link then it will not support engOpen.
also engOpen("") should work
This is not quite all that there is to it, there are certain mods that you have to keep in mind for the IDE configuration (or the linker and include options if you're using a command-line compiler).
Here's a Matlab admin page to resolve these problems. Beyond the COM link issue.
https://www.mathworks.com/matlabcentral/answers/100603-how-can-i-compile-a-matlab-engine-application-using-microsoft-visual-studio-9-0-or-10-0
如果您查看
engOpen
文档,说:在 Windows 系统上,engOpen 打开一个到 MATLAB 的 COM 通道。您在安装过程中注册的 MATLAB 软件将会启动。如果您在安装过程中没有注册,则可以在命令行中输入命令:
我不确定这是您的问题,但似乎值得一试。
If you look at the
engOpen
documentation it says:On Windows systems, engOpen opens a COM channel to MATLAB. The MATLAB software you registered during installation starts. If you did not register during installation, on the command line you can enter the command:
I'm not sure that is your problem, but it seems worth a try.