Generate custom ROS messages in Matlab running on Windows using Cmake from Ubuntu install on WSL2

35 views (last 30 days)
I'm trying to integrate Simulink running on Windows with a rosnode setup in Ubuntu 18.04 running in WSL2 on the same physical machine. The link seems to be working so that I can publish ROS messages from Simulink to the ROS node on linux, but I'm having problems generatying custom ROS messages in matlab with rosgenmsg() since my CMake compiler is located on the linux VM. Is there any way that I can point matlab to the CMake executable on my WSL2 setup?
I've been following the tutorial on custom ROS messages here (
here's where I'm at so far:
>> folderpath = fullfile('//wsl$/Ubuntu-18.04/home/eric/catkin_ws','src'); % set path to catkin workspace on WSL2 setup
>> rosgenmsg(folderpath) % Attempt to generate ROS messages
Identifying message files in folder '//wsl$/Ubuntu-18.04/home/eric/catkin_ws/src'..Done.
Validating message files in folder '//wsl$/Ubuntu-18.04/home/eric/catkin_ws/src'..Done.
[0/1] Generating MATLAB interfaces for custom message packages... 0%Error using ros.internal.utilities.getCMakeBinaryPath (line 19)
Could not find CMake in your system. Please install CMake version 3.15.5 or higher and rerun the command.
Error in ros.internal.CatkinBuilder.getCMakePath (line 82)
[aPath, aVersion] = ros.internal.utilities.getCMakeBinaryPath(ros.internal.CatkinBuilder.CMAKEMINVERSION);
Error in ros.internal.ROSProjectBuilder (line 391)
h.CMakePath = h.getCMakePath();
Error in ros.internal.CatkinBuilder (line 24)
Error in rosgenmsg (line 223)
builder = ros.internal.CatkinBuilder(genDir, pkgInfos{iPkg});
I have CMake 3.19 installed in Ubuntu on WSL2, but obviously Matlab isn't able to access this since it's running on Windows. Is there any way that I can point matlab to this CMake executable?

Accepted Answer

Cam Salzberger
Cam Salzberger on 2 Mar 2021
Hello Eric,
You will need CMake installed on your Windows system, along with Visual Studio 2017 and Python 2.7. It's unlikely that the versions installed on your Ubuntu WSL2 would be configured correctly for building files on Windows, and a Windows-compatible compiler would be necessary in any case. CMake can easily be installed on Windows - just make sure it's on the system PATH.
Cam Salzberger
Cam Salzberger on 13 May 2021
I just saw your new question regarding this issue and responded there, before I saw this comment. Hopefully that answer can point you in the right direction.

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!