当前位置:网站首页>配置用命令行编译的环境-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
四、参考
边栏推荐
- 牛客网:数组中只出现一次的两个数字
- OpenJudge NOI 1.13 18:Tomorrow never knows?
- Prophet
- 怎样确保消息的可靠性投递?
- TCP/IP
- Forest v1.5.22 release! Kotlin support
- [Fibonacci series]
- JS memory leak
- Explication du cours de graphacademy: neo4j Graph Data Science Foundation
- 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
猜你喜欢

JS memory leak

Go language advantages and learning Roadmap

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

AOSP ~ modify WebView default implementation

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

Rs232/rs485 to 4G DTU uploading temperature and humidity sensor data based on Modbus protocol to remote TCP server

How to fix syntax errors in WordPress websites

Correct posture of cocoscreator's native secondary development

The Google search console webmaster tool cannot read the sitemap?

蓝桥杯_小蓝吃糖果_鸽巢原理 / 抽屉原理
随机推荐
Three special data types, day3 and redis (geographic location, cardinality statistics and bitmap scene usage)
怎样确保消息的可靠性投递?
那些笑着离开“北上广”的人,为何最后都哭了?
判断一串数字是否是快速排序某一次的结果
Prophet
ORA-00392 ORA-00312 错误处理
Graphacademy course explanation: Fundamentals of neo4j graph data science
Baidu submits sitemap to prompt the solution of "index type is not handled"
Stringutils string tool class used by FreeMarker to create templates
【大咖秀】博睿数据眼中的AIOps,选择正确的赛道正确的人
弄懂了采矿业与碳中和的逻辑,就读懂了矿区无人驾驶的千亿市场
新来的同事问我 where 1=1 是什么意思???
msg=SolrCore ‘collection1‘ is not available due to init failure: Could not l
近期学习和更新计划
TCP/IP
JS memory leak
Why did those who left Beijing, Shanghai and Guangzhou with a smile cry in the end?
com. mchange. v2.c3p0. Combopooleddatasource red
[resolved] how to fix another update in progress WordPress upgrade error
Live broadcast! Feature matching of orb-slam3 series (mlpnp, word bag model, etc.).