System error:Shar​edMemory:g​etCurrentU​ser:getlog​in_r:error​=25 on wsl when connecting to Matlab from C++ with matlab::en​gine::conn​ectMATLAB(​)

1 次查看(过去 30 天)
I'm using C++ to run a MATLAB script. The code is simple:
std::cout << "Starting matlab" << std::endl;
matlab = matlab::engine::startMATLAB();
std::cout << "matlab started, connecting to matlab" << std::endl;
matlab::engine::connectMATLAB();
std::cout << "Connected to MATLAB" << std::endl;
MATLAB can be started, but not connected to. I never reach the last line of the code. Instead, I receive the following error:
terminate called after throwing an instance of 'std::runtime_error'
what(): System error:SharedMemory:getCurrentUser:getlogin_r:error=25
I have MATLAB installed and include
#include "MatlabDataArray.hpp"
#include "MatlabEngine.hpp"
This is most likely somehow related to the fact that I'm running this on WSL (kernel 5.10.16.3-microsoft-standard-WSL2). The same code works on a real Ubuntu 20.04 (not wsl).
Not sure if related, but always the first time I start MATLAB from WSL after a reboot of WSL, I need to reactivate it.
The host machine I'm using runs on Windows 11.
  1 个评论
Raghav Bansal
Raghav Bansal 2023-12-26
I think similar issue was resolved in the latest release of the MATLAB i.e. R2023b. You may try to install the latest release and check if the issue still persists.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 C Shared Library Integration 的更多信息

产品


版本

R2022a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by