依赖gcc、 cmake
1. 模板编写
main.cpp
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World!" << endl;
return 0;
}
2. cmake 编写
CMakeLists.txt
project(test)
cmake_minimum_required(VERSION 2.8)
set(CMAKE_CXX_STANDARD 11)
set(CMAKE_BUILD_TYPE "Debug")
include_directories(
${PROJECT_SOURCE_DIR})
aux_source_directory(./ SRC_LIST)
add_executable(${PROJECT_NAME} ${SRC_LIST})
target_link_libraries(${PROJECT_NAME}
-ldl -lm -lpthread -lrt)
3. 测试运行
cd test
mkdir build
cd build
cmake ..
make
./test
网友评论