Referring to https://stackoverflow.com/a/78466486/13059668
If you want to use CmakeLists add the following line after add_executable
add_executable
target_link_libraries(${PROJECT_NAME} PRIVATE "-lstdc++exp")