Issue
I have cloned the latest version of OpenPose and try to build it on MacOS 13.5 (22G74). After I run make -j sysctl -n hw.logicalcpu
it generates a bunch of errors saying that I used an outdated c++ version:
/usr/local/include/google/protobuf/port_def.inc:205:1: error: static_assert failed due to requirement '201103L >= 201402L' "Protobuf only supports C++14 and newer."
static_assert(PROTOBUF_CPLUSPLUS_MIN(201402L), "Protobuf only supports C++14 and newer.");
^ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/usr/local/include/absl/base/policy_checks.h:79:2: error: "C++ versions less than C++14 are not supported."
#error "C++ versions less than C++14 are not supported."
So I searched through the CMakeLists.txt and added these lines on the top of the file:
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)
also changed part of the c++ flags section to std=c++14
:
elseif (UNIX)
# Turn on C++14
add_definitions(-std=c++14)
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
elseif (APPLE)
# Turn on C++14
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14")
set(CMAKE_CXX_FLAGS_RELEASE "-O3")
endif (WIN32)
# C++ additional flags
if (CMAKE_COMPILER_IS_GNUCXX)
message(STATUS "GCC detected, adding compile flags")
# set(OP_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp -Wpedantic -Wall -Wextra -Wfatal-errors")
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fopenmp")
set(OP_CXX_FLAGS "${CMAKE_CXX_FLAGS} -Wpedantic -Wall -Wextra -Wfatal-errors")
# set(CUDA_NVCC_FLAGS "${CUDA_NVCC_FLAGS} -Wpedantic -Wall -Wextra -Wfatal-errors")
endif (CMAKE_COMPILER_IS_GNUCXX)
then remove the build folder and do the steps all over again, but still got the same errors. I check the CMake Configuration Summery in the Terminal, found out the flag is still set to version 11 for c++:
-- ******************* Caffe Configuration Summary *******************
-- General:
-- Version : 1.0.0
-- Git : 1.0-149-g1807aada
-- System : Darwin
-- C++ compiler : /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Release CXX flags : -O3 -DNDEBUG -fPIC -Wall -std=c++11 -Wno-sign-compare -Wno-uninitialized
-- Debug CXX flags : -g -fPIC -Wall -std=c++11 -Wno-sign-compare -Wno-uninitialized
-- Build type : Release
Right now I have no idea how to change the flags and compiler version. I also can't find how to change this in cmake-gui, the gui looks like this: Any solution is welcome!
Solution
Turns out I was modifying the wrong CMakeLists.txt file. The correct one should be under the path:openpose/3rdparty/caffe/CMakeLists.txt
.
Then change the flag here to other versions:
# ---[ Flags
if(UNIX OR APPLE)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -fPIC -Wall -std=c++17")
endif()
This should do the work.
Answered By - YPZ404 Answer Checked By - David Goodson (WPSolving Volunteer)