System error:SharedMemory:getCurrentUser:getlogin_r:error=25 on wsl when connecting to Matlab from C++ with matlab::engine::connectMATLAB()
1 view (last 30 days)
Show older comments
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 Comment
Raghav Bansal
on 26 Dec 2023
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.
Answers (0)
See Also
Categories
Find more on Introduction to Installation and Licensing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!