I am trying to install the MMMTools https://mmm.humanoids.kit.edu/installation.html. My cmake version is 3.16.3. I went through every step without any errors until this section
cd ~/MMMCore
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
make
The make
command returns me the following error.
(base) kong@kong-Standard:~/MMMCore/build$ make
[ 1%] Building CXX object CMakeFiles/MMMCore.dir/MMM/XMLTools.cpp.o
/home/kong/MMMCore/MMM/XMLTools.cpp: In function ‘void MMM::XML::makeAbsolutePath(const string&, std::string&)’:
/home/kong/MMMCore/MMM/XMLTools.cpp:650:64: error: ‘operator/’ is not a member of ‘std::filesystem’; did you mean ‘operator~’?
650 | std::filesystem::path filenameNewComplete = std::filesystem::operator/(filenameBasePath, filenameNew);
| ^~~~~~~~~
| operator~
make[2]: *** [CMakeFiles/MMMCore.dir/build.make:76: CMakeFiles/MMMCore.dir/MMM/XMLTools.cpp.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:295: CMakeFiles/MMMCore.dir/all] Error 2
make: *** [Makefile:163: all] Error 2
But I googled the function and saw that it is a member of std::filesystem https://en.cppreference.com/w/cpp/filesystem/path/operator_slash. What went wrong?
I had a look through the CMakeLists.txt and saw this.
###########################################################
#### Compiler configuration ####
###########################################################
set(CMAKE_POSITION_INDEPENDENT_CODE ON) # enable -fPIC
if(MSVC)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /W4 /MP")
elseif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
# cmake 3.10 does not understand c 2a, so we tell it we will handle the standard flag
set(CMAKE_CXX_STANDARD_DEFAULT)
add_definitions(-std=c 2a)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
endif()
add_compile_options(-Werror)
I am compiling it on Ubuntu 20.04 so I guess it enters the elseif section. Does it mean that it is not using C 17? Do I need to edit the line set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wall -Wno-long-long -pedantic")
to have it use C 17?
The guide indicates that it is for 18.04 but since the issue is with C 17 I don't think the fault lies in using 20.04?
CodePudding user response:
Due to LWG 3065 the operator is now hidden and shouldn't be called directly.
std::filesystem::path filenameNewComplete = std::filesystem::operator/(filenameBasePath, filenameNew);
Should just be:
std::filesystem::path filenameNewComplete = filenameBasePath / filenameNew;
I'm guessing the code has only been tested against an older implementation (it looks like this was implemented in gcc/libstdc 9) than the one you are using, I don't know why it was written in such an overcomplicated way initially though.