By default, CentOS 7 supports C++ up to 2011 (C++11). For C++17 (2017) support with Eclipse IDE:
- Login to CentoOS 7 as root.
- Open terminal.
- Install Developer Toolset 8: yum install dev-toolset-8
- cd into Eclipse folder.
- Enable toolset 8 for Eclipse and open it: scl enable devtoolset-8 ./eclipse
- After Eclipse opens, open/create a C++ project, use this filesystem example.
- Go to project properties - C/C++ Build - Settings - Tool Settings - GCC C++ Compiler - Dialect - Other dialect flags and enter -std=c++17:
- Now you can build your project using C++ 2017 features. If you print __cplusplus, you get 201703. Note that project include folders point to devtoolset-8:
Rebuild index. Now you can compile but still get linker error.
Add linker flag -lstdc++fs and reorder linker flags so that -lstdc++fs is at the end: ${COMMAND} ${OUTPUT_FLAG} ${OUTPUT_PREFIX}${OUTPUT} ${INPUTS} ${FLAGS}
Now you can successfully run the example.
No comments:
Post a Comment