C++代码如下:
#include <cstdlib>
#include <iostream>
#include <string>
std::string say_hello()
{
return std::string("hello word!");
}
int main(int argc,char** argv)
{
std::cout<<say_hello()<<std::endl;
return EXIT_SUCCESS;
}
cmake .. 之后,出现如下错误
CMakeList.txt内容如下:
cmake_minimum_required(VERSION 3.5 FATAL_ERROR)
project(hello-world-01 LANGUAGES CXX)
SET(CMAKE_CXX_COMPILER /usr/bin/g++)
add_executable(hello-world hello-world.cpp)
在 CMakeLists.txt 中添加如下命令,指定 g++ 为编译器。
SET(CMAKE_CXX_COMPILER /usr/bin/g++)