1

我正在尝试通过 cmake 文件构建我的项目。并开始得到:

fatal error: string_view: No such file or directory

对于下面的行:

// Your First C++ Program


#include <string_view>


int main() {
    std::cout << "Hello World!";
    return 0;
}

我在互联网上查找,在 stackoverflow 问题中指出这是因为 GCC 版本:String_view question

我将我的 gcc 版本更新为:

gcc --version
gcc (Ubuntu 7.5.0-3ubuntu1~16.04) 7.5.0
Copyright (C) 2017 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

但问题仍然存在。我还使用 C++ 17,如下 Cmake 行:

cmake_minimum_required(VERSION 3.0)

set(CMAKE_BUILD_TYPE Debug)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++17")

project (sample)

add_executable(
    main
    main.cpp
)


# Set include directories
include_directories(SYSTEM

)

# Set linked files
link_directories(

)

target_link_libraries(
    main )

可能是什么问题呢?为什么我不能编译代码?

4

0 回答 0