Home › Forum › SOFA › Building SOFA › [SOLVED] Clang error while compiling Sofa
Tagged: 64_bits, GCC, Linux_other, SOFA_2006
- This topic has 2 replies, 2 voices, and was last updated 3 years, 11 months ago by Hugo.
-
AuthorPosts
-
30 November 2020 at 19:41 #17790SimitBlocked
Hello,
I am trying to build SOFA v20.06 and I have followed all the instructions on this page: https://www.sofa-framework.org/community/doc/getting-started/build/linux/
I am using clang-7 and cmake 3.19. During the ninja build I am getting the below error
[157/1552] Building CXX object SofaKernel/SofaFramework/SofaHel...r/CMakeFiles/SofaHelper.dir/src/sofa/helper/AdvancedTimer.cpp.o FAILED: SofaKernel/SofaFramework/SofaHelper/CMakeFiles/SofaHelper.dir/src/sofa/helper/AdvancedTimer.cpp.o /usr/bin/clang++-7 -DNDEBUG -DSOFA_BUILD_HELPER -DSOFA_BUILD_SOFAHELPER -DSofaHelper_EXPORTS -I/home/one/Projects/sofa/src/SofaKernel/modules/SofaHelper/src -I/home/one/Projects/sofa/src/SofaKernel/modules/SofaHelper/../SofaSimulationCore/src -I/home/one/Projects/sofa/src/SofaKernel/modules/SofaHelper/../SofaDefaultType/src -I/home/one/Projects/sofa/src/SofaKernel/modules/SofaHelper/../SofaCore/src -Iinclude/SofaFramework -Iinclude/GTest -isystem /home/one/Projects/sofa/src/SofaKernel/extlibs/json -isystem /home/one/Projects/sofa/src/extlibs/gtest/include -isystem /usr/include/eigen3 -Wall -W -Wno-padded -O3 -DNDEBUG -fPIC -DFRAMEWORK_TEST_RESOURCES_DIR=\"/home/one/Projects/sofa/src/SofaKernel/SofaFramework/resources/tests\" -pthread -DGTEST_LINKED_AS_SHARED_LIBRARY=1 -std=gnu++17 -MD -MT SofaKernel/SofaFramework/SofaHelper/CMakeFiles/SofaHelper.dir/src/sofa/helper/AdvancedTimer.cpp.o -MF SofaKernel/SofaFramework/SofaHelper/CMakeFiles/SofaHelper.dir/src/sofa/helper/AdvancedTimer.cpp.o.d -o SofaKernel/SofaFramework/SofaHelper/CMakeFiles/SofaHelper.dir/src/sofa/helper/AdvancedTimer.cpp.o -c /home/one/Projects/sofa/src/SofaKernel/modules/SofaHelper/src/sofa/helper/AdvancedTimer.cpp In file included from /home/one/Projects/sofa/src/SofaKernel/modules/SofaHelper/src/sofa/helper/AdvancedTimer.cpp:28: In file included from /home/one/Projects/sofa/src/SofaKernel/extlibs/json/../../extlibs/json/json.h:5: /home/one/Projects/sofa/src/SofaKernel/extlibs/json/nlohmann_json.h:12436:59: error: no type named 'string_view' in namespace 'std' and not std::is_same<ValueType, typename std::string_view>::value ~~~~~~~~~~~~~~^~~~~~~~~~~ 1 error generated.
Upon some searching I came across topics which said that since
string_view
is available C++17 onwards. Is there an alternative version of clang that I should use for the compilation?I am on Debian Stretch and am stuck with gcc-6.3
What would be my options to build Sofa successfully?
Regards,
Simit30 November 2020 at 19:41 #17800SimitBlockedI was able to fix this problem by including the necessary file as recommended in SO.
Here’s my patch that helped fix this problem. I am not sure if this is a hack or a legitimate fix.
diff --git a/SofaKernel/extlibs/json/nlohmann_json.h b/SofaKernel/extlibs/json/nlohmann_json.h index e02f62b146..c79ecabc62 100644 --- a/SofaKernel/extlibs/json/nlohmann_json.h +++ b/SofaKernel/extlibs/json/nlohmann_json.h @@ -54,6 +54,7 @@ SOFTWARE. #include <memory> // allocator #include <string> // string #include <vector> // vector +#include <experimental/string_view> /*! @brief namespace for Niels Lohmann @@ -12433,7 +12434,7 @@ namespace nlohmann and not std::is_same<ValueType, std::initializer_list<typename string_t::value_type>>::value #endif #if defined(JSON_HAS_CPP_17) - and not std::is_same<ValueType, typename std::string_view>::value + and not std::is_same<ValueType, typename std::experimental::string_view>::value #endif , int >::type = 0 > operator ValueType() const
9 December 2020 at 21:30 #17990 -
AuthorPosts
- You must be logged in to reply to this topic.