2b-t / myactuator_rmd

C++ and Python SDK for controlling actuators of the MyActuator RMD-X series, written in C++ with Python bindings
MIT License
15 stars 12 forks source link

‘is_integral_v’ is not a member of ‘std’ #14

Closed robodyne-robotics closed 3 days ago

robodyne-robotics commented 3 days ago

Hello,

I looked in the closed issues and I found a similar problem, but it was on Raspberry. I'm on Ubuntu 20.04, my g++ version is 9.4.0 and my cmake is 3.16.3. I had to change the cmake version in the main CMakeLists.txt file as: cmake_minimum_required(VERSION 3.16)

I'm able to compile the library without any errors, but when I try to compile a sample C++ program as the one mentioned in the readme file, I get this error:

/usr/local/include/myactuator_rmd/protocol/message.hpp:65:60: error: ‘is_integral_v’ is not a member of ‘std’; did you mean ‘is_integral’?
   65 |       template <typename T, typename std::enable_if_t<std::is_integral_v<T>>* = nullptr>
      |                                                            ^~~~~~~~~~~~~
      |                                                            is_integral

I have this problem only on Ubuntu 20.04, since everything works fine on Ubuntu 22.04. Also, On Ubuntu 20.04, I had to modify .len to can_dlc while I had to do nothing on Ubuntu 22.04 since everything worked fine.

I think it is a compiler problem, but I cannot upgrade it because I would damage my ROS Noetic installation.

How can I solve it?

2b-t commented 3 days ago

Hi @robodyne-robotics I think your error is due to G++ 9.4.0 not compiling with support for C++17 as a default. I am targetting Ubuntu 22.04 and onwards with this code in combination with C++17 as Ubuntu 20.04 is reaching its end of life soon. Add the following to the CMake file to enforce it:

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

This should solve your issue.

robodyne-robotics commented 3 days ago

Yes, thank you, it works like a charm!

I post here the code in case someone needs it to compile on Ubuntu 18.04 and Ubuntu 20.04:


cmake_minimum_required(VERSION 3.16)
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

project(test_code)

find_package(myactuator_rmd REQUIRED)

add_executable(test
  main.cpp
)
target_link_libraries(test PUBLIC myactuator_rmd::myactuator_rmd)
robodyne-robotics commented 3 days ago

done

2b-t commented 3 days ago

You are welcome. I will add it to the read-me!