如何只利用NMAKE+CL+LINK写WIN32程序

关键是
1.包含<Windows.h>及其他的相关头文件
2.在LINK指令中最起码要加上KERNEL32.LIB USER32.LIB GDI32.LIB(不需要制定其路径,因为NMAKE, CL和LINK都来自VS,这3个LIB文件都是默认配置好的),这三个LIB文件包含了所需的其他DLL的信息。当然,不止这三个,但这三个是最基本的,如果还需要其他的,建议可以打开VS创建一个WIN32 project,然后通过Project>Properties>Linker>Input (or Command line)查看还需要哪些其他的LIB文件

补充说明:

摘自下面demo的Makefile
"For more libraries of WINAPI you can create a WIN32 application in VS and inspect the project's linker options.
Select Project>Properties>Linker>Input (or Command line) so you can see all LIB files needed by a WIN32 applicatin.
These 3 LIB files contain names and reference information of the dynamic-link libraries to be bound to the generated exe file."


摘自Programming Windows 5th Edition, by Charles Petzold
"As normal, during the compile stage, the compiler generates an .OBJ (object) file from the C source code file.
During the link stage, the linker combines the .OBJ file with .LIB (library) files to create the .EXE (executable) file.
You can see a list of these library files by selecting Settings from the Project tab and clicking the Link tab. In
particular, you'll notice KERNEL32.LIB, USER32.LIB, and GDI32.LIB. These are "import libraries" for the three
major Windows subsystems. They contain the dynamic-link library names and reference information that is bound
into the .EXE file. Windows uses this information to resolve calls from the program to functions in the
KERNEL32.DLL, USER32.DLL, and GDI32.DLL dynamic-link libraries"

这是一个HELLO WORLD的WIN32 DEMO,点击下载

 

转载于:https://www.cnblogs.com/qrlozte/p/4381885.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值