当前位置:网站首页>Cpp(二) 创建Cpp工程
Cpp(二) 创建Cpp工程
2020-11-07 20:58:00 【Coxhuang】
文章目录
- 第一个Cpp例子
- #1 环境
- #2 概述
- #3 开始
- #3.1 方法一:Clion
- #3.2 方法二:手动创建
第一个Cpp例子
#1 环境
macOS 10.15.5
#2 概述
本文通过两种方式创建一个简单的Cpp工程,对比两种方法的异同,这里不解释各个文件的作用,仅仅只是介绍两种创建Cpp工程的方法
#3 开始
GitHub例子:https://github.com/Coxhuang/FKCpp/tree/master/1.first_demo
#3.1 方法一:Clion
- 新建工程
- 运行main.cpp
#3.2 方法二:手动创建
- 创建如下文件 :
build CMakeLists.txt main.cpp
其中 :
- build: 空文件夹
- CMakeLists.txt内容如下 :
cmake_minimum_required(VERSION 3.16) project(demo) set(CMAKE_CXX_STANDARD 11) add_executable(demo_exe main.cpp)
- main.cpp内容如下 :
//
// Created by Cox on 2020/8/30.
//
#include <iostream>
int main() {
std::cout << "Hello, World!" << std::endl;
return 0;
}
2. cmake
- 使用terminal进入built目录下
cmake ..
3. make编译
- 在built目录下
make
4. 运行
- 在built目录下,运行可执行文件
./demo_exe
本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。
版权声明
本文为[Coxhuang]所创,转载请带上原文链接,感谢
https://cloud.tencent.com/developer/article/1744571
边栏推荐
- 微服务的出现和意义的探索
- [漫谈] 软件设计的目标和途径
- 三步一坑五步一雷,高速成长下的技术团队怎么带?
- How Facebook open source framework simplifies pytorch experiment
- Tips for Mac novices
- Facebook开源框架如何简化 PyTorch 实验
- Exception calling 'downloadstring' with '1' arguments: 'operation timed out'
- The most hard core of the whole network explains the computer startup process
- 在pandas中使用pipe()提升代码可读性
- 如何以计算机的方式去思考
猜你喜欢
随机推荐
Mac新手必备小技巧
Do not understand the underlying principle of database index? That's because you don't have a B tree in your heart
Using pipe() to improve code readability in pandas
洞察——风格注意力网络(SANet)在任意风格迁移中的应用
快速上手Git
[random talk] the goal and way of software design
「混合云」会是云计算的下一个战场吗?
阿里terway源码分析
一次公交卡被“盜刷”事件帶來的思考
Stack bracket matching
某618大促项目的复盘总结
Code Review最佳实践
In the age of screen reading, we suffer from attention deficit syndrome
Exploration and practice of growingio responsive programming
华为HCIA笔记
Principles of websocket + probuf
From technology to management, the technology of system optimization is applied to enterprise management
Recommend suicide, openai warns: gpt-3 is too risky for medical purposes
Web API series (3) unified exception handling
Kubernetes服务类型浅析:从概念到实践








