简体   繁体   English

engOpen 返回 Null

[英]engOpen returns Null

I'm having a problem when I try to call a Matlab funcion from my C++ code.当我尝试从我的 C++ 代码调用 Matlab 函数时遇到问题。

When I call engOpen, it always returns NULL.当我调用 engOpen 时,它总是返回 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 !!!谢谢 !!!

If you look at theengOpen documentation it says:如果您查看engOpen文档,它会说:

On Windows systems, engOpen opens a COM channel to MATLAB.在 Windows 系统上,engOpen 打开 COM 通道到 MATLAB。 The MATLAB software you registered during installation starts.您在安装过程中注册的 MATLAB 软件启动。 If you did not register during installation, on the command line you can enter the command:如果安装时没有注册,可以在命令行输入命令:

matlab /regserver

I'm not sure that is your problem, but it seems worth a try.我不确定这是你的问题,但似乎值得一试。

you need to launch Matlab in administrator mode right-click on the Matlab icon and select "run as administrator"您需要在管理员模式下启动 Matlab 右键单击 Matlab 图标和 select “以管理员身份运行”

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.即使您在管理员期间注册了 Matlab,您也应该检查这一点,如果它当前没有注册为 COM 链接,那么它将不支持 engOpen。

also engOpen("") should work engOpen("") 也应该工作

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).这还不是全部,对于 IDE 配置(或 linker 并包含选项,如果您使用命令行编译器),您必须记住某些模块。

Here's a Matlab admin page to resolve these problems.这是解决这些问题的 Matlab 管理页面。 Beyond the COM link issue.除了 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 https://www.mathworks.com/matlabcentral/answers/100603-how-can-i-compile-a-matlab-engine-application-using-microsoft-visual-studio-9-0-or-10-0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM