当前位置:网站首页>配置用命令行编译的环境-MSVC
配置用命令行编译的环境-MSVC
2022-06-11 02:43:00 【shlyyy】
配置用命令行编译的环境--MSVC
虽然vs2019是非常好用的IDE,但有时候命令行编译会更简单好用,下面就是用配置使用MSVC编译程序的环境。
一、安装vs2019
vs安装的话网上一大堆啦,不会的话自己百度就行啦
二、配置环境变量
安装完vs2019以后会发现在vs2019的同盘符下会有一个Windows Kit文件夹。
打开环境:
点击第一个系统
找到最下面的关于,在相关设置栏目下有一个高级系统设置

新建 WIN10_INCLUDE 环境变量
E:\Windows Kits\10\Include\10.0.19041.0
新建 WIN10_LIB 环境变量
E:\Windows Kits\10\Lib\10.0.19041.0
新建 MSVC 环境变量:
E:\Program Files (x86)\Microsoft Visual Studio\2019\Professional\VC\Tools\MSVC\14.29.30133
新建 INCLUDE 环境变量,添加以下4项内容:
%WIN10_INCLUDE%\ucrt
%WIN10_INCLUDE%\shared
%WIN10_INCLUDE%\um
%MSVC%\include
新建 LIB 环境变量,添加以下两项内容:
%MSVC%\lib\x86
%WIN10_LIB%\ucrt\x86;%WIN10_LIB%\um\x86
我这里选择的是编译32位的程序,所以是x86文件夹,如果是64位程序可以改成x64,下面的也一样。
在 Path 环境变量里添加以下路径
%MSVC%\bin\Hostx86\x86
三、测试环境
新建test.c文件
#include <stdio.h>
int main()
{
printf("Hello world!\r\n");
return 0;
}
打开命令行,切换路径到test.c所在的文件夹下:
执行以下编译指令后会生成一个test.obj文件
cl /c /W3 test.c
执行以下链接指令会生成一个test.exe可执行文件
link test.obj
最后直接输入test即可执行test.exe
为了方便直接,执行以下run.bat脚本,即可编译,链接,执行:
del *.obj
del *.exe
cl /c test.c /W3
link test.obj
test.exe
pause
四、参考
边栏推荐
- Arduino uno connected to jq8900-16p voice broadcast module
- CocosCreator原生二次开发的正确姿势
- How to ensure reliable delivery of messages?
- AOSP ~ 修改默认音量
- 那些笑着离开“北上广”的人,为何最后都哭了?
- Blue Bridge Cup_ Xiao Lan eats candy_ Pigeon nest principle / drawer principle
- What is the difference between a database unique index and a common index?
- ROS基础 - 使用 launch 文件(一) - 批量启动多个ROS节点
- Niuke: two numbers that only appear once in the array
- B_ QuRT_ User_ Guide(20)
猜你喜欢

Go language advantages and learning Roadmap

同一个用户的两次请求SessionId竟然不一致-----记录问题
![[implementation of bubble sorting]](/img/c9/5e4aa246c89fd03a184dbd00161f97.png)
[implementation of bubble sorting]

com. mchange. v2.c3p0. Combopooleddatasource red

第七章 常用的协议简介(1)

Win10 安装Office 2016出现错误代码30204-44怎么处理?

你的公司会选择开发数据中台吗?

Live broadcast! Feature matching of orb-slam3 series (mlpnp, word bag model, etc.).

JS memory leak

msg=SolrCore ‘collection1‘ is not available due to init failure: Could not l
随机推荐
CocosCreator原生二次开发的正确姿势
jdbc工具类的问题
HOSATAPD_ CLI debug using WiFi whitelist
AOSP ~ logcat chatty line expired
HUST软件工程(实验2)--TDD测试驱动开发实验。
Whether the outbound sequence is the inbound sequence
MySQL is required to sort in ascending order greater than or equal to the current time, and then in descending order less than the current time
Determine whether a string of numbers is the result of a quick sort
How to add two factor authentication for WordPress websites
Three special data types, day3 and redis (geographic location, cardinality statistics and bitmap scene usage)
Stringutils string tool class used by FreeMarker to create templates
反射三种方式
Chapter VII introduction to common protocols (1)
微信模版消息errcode“:40165,“errmsg“:“invalid weapp pagepath
The new colleague asked me what "where 1=1" means???
AOSP ~ WiFi on by default + GPS off by default + Bluetooth off by default + rotary screen off
Graphacademy course explanation: Fundamentals of neo4j graph data science
Why did those who left Beijing, Shanghai and Guangzhou with a smile cry in the end?
WordPress upgrade error: briefly unavailable for scheduled maintenance [resolved]
ORA-00392 ORA-00312 错误处理