Generate custom ROS messages in Matlab R2021a running on MacOS 11.4 with CMake 3.20.5. Error: Could not find CMake in your system

8 views (last 30 days)
Hello,
I have been trying to import custom ROS messages into Matlab R2021a using the rosgenmsg command as follows:
rosgenmsg(folderpath)
and I get the following error message:
Identifying message files in folder '/Users/Documents/MATLAB/custom_ros_msgs/packages'..Done.
Validating message files in folder '/Users/Documents/MATLAB/custom_ros_msgs/packages'..Done.
[0/2] 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 390)
h.CMakePath = h.getCMakePath();
Error in ros.internal.CatkinBuilder (line 24)
h@ros.internal.ROSProjectBuilder(varargin{:});
Error in rosgenmsg (line 223)
builder = ros.internal.CatkinBuilder(genDir, pkgInfos{iPkg});
I have CMake installed, and when I checked for my CMake version and location in Terminal, and I get the following output:
cmake --version
- cmake version 3.20.5
which cmake
/Applications/CMake.app/Contents/bin/cmake
It looks to me that Matlab is not able to find the CMake path.
How could I update the CMake path in Matlab, or point it to CMake?
Any help getting this to work will be much appreciated!
I have the following setup:
Matlab Version: R2021a
OS: MacOS 11.4
CMake version: CMake 3.20.5
I have previously used rosgenmsg with Matlab R2018a, and the workflow was different in that version.

Accepted Answer

Josh Chen
Josh Chen on 1 Jul 2021
Hello Sriharsha,
This seems to be an issue with MATLAB custom LD_LIBRARY_PATH. To confirm this, could you please try running the following command in MATLAB Command Window:
>> !cmake --version
If this also returns information about CMake not found, then we are sure LD_LIBRARY_PATH is the root cause. In that case, please refer to this discussion to set the LD_PRELOAD, note that you may need to replace the path to libstdc++.so.6 and libcurl.so by the actual path on Mac.
Our team is aware of this issue already and is actively working on addressing this in an upcoming update.
Hope this helps!
Josh
  1 Comment
Sriharsha Bhat
Sriharsha Bhat on 5 Jul 2021
Edited: Sriharsha Bhat on 5 Jul 2021
Hi Josh,
Thank you very much for your answer. It was very helpful!
Following your recommentation, I ran
!cmake --version
in Matlab, and it couldn't find CMake. So it did look like the PATH was the root cause.
After that I followed the instructions in the discussion you shared, and entered the following line in the Matlab command window to set the PATH:
setenv('PATH', strcat('/usr/local/bin', pathsep, getenv('PATH')))
Following that, running >> !cmake--version returned my CMake version (3.20.5).
I ran rosgenmsg after that, and I was able to successfully generate custom ROS messages.
I hope this 'fix' helps others who get stuck with the same issue. Looking forward to the next update!
Best regards,
Sriharsha

Sign in to comment.

More Answers (0)

Categories

Find more on ROS Custom Message Support in Help Center and File Exchange

Products


Release

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by