


Win32 SDK Basics (2) Detailed explanation of the cl.exe and link.exe compilation and linking procedures (picture)
一 Start with the compilation process of the program
## We introduced windows in the previous article Knowledge of the classification of programs under the system, compilers, connectors, commonly used header files, library files, etc. This article will talk about the compilation process of the program.
I believe everyone knows that the compilation process of source code is divided into two steps: First, the compilation process, the main job is to translate our source code into intermediate files, which is in windows is the function of cl.exe, it will use our .c file or The .cpp file is translated into an intermediate .obj file; the second is the connection process. The main job is to connect various intermediate files and library files to generate an executable file. This is the role of link.exe in windows, it will .objFiles and library files are linked into exe programs.
This article mainly teaches you to get rid of the IDE of VS and use the command line to use cl.exe and link.exe compile and link the program.
二 Write our Test.c file
## First We create a newtest.txt file and rename it to text.c. In this file we fill in the following code: #include "windows.h"
int APIENTRY wWinMain(_In_ HINSTANCE hInstance,
_In_opt_ HINSTANCE hPrevInstance,
_In_ LPWSTR lpCmdLine,
_In_ int nCmdShow)
{
MessageBox(NULL,"Hello Win32","sdk",MB_ABORTRETRYIGNORE|MB_ICONERROR);
return 0;
}
windows system. Then we introduced the main function of the windows window programwWinMain. Here is a brief explanation of the role of each formal parameter in Winmain: hInstance is the instance handle of the current program, which is the memory where the current program is located. The position; hPrevInstanceThe handle of the previous instance of the current program, which has been abandoned; lpCmdLine is the command line parameter, that is, we use the command line When executing the program, you can attach some strings as parameters; nCmdShow is the window display mode, maximize or minimize. We called MessageBox in the main function to define a modal dialog box. If the compilation is successful, a dialog box will pop up after we execute the program.
Now that theTest.c file has been written, the next thing we have to do is compile and link the files separately.
三 CompileTest.c
We will openwindows The cmd command line tool, then switch to our current working directory and compile the Test.c file using the following command: Cl.exe /c test.c
After compilation is completed, the test.obj intermediate file will be generated in the working directory:
If your command line prompt cannot find the cl.exe command and other information, I believe you should understand that this is because the environment variable does not exist To import the directory where cl.exe is located, we can first add the environment variable or use the full path to import. If you generate the test.obj file, it means that the compilation process is completed and we can start the connection process.
4. Link generationtest.exe
Next we execute the following command to generate the executable file:
Link.exe test.obj user32.lib
User32.libWe mentioned this library in the previous article. It contains the desired user interface and message-related API. The MessageBox we need to call is defined in this library. , if nothing goes wrong, the executable file test.exe should be generated in your working directory:
## Double-click this exe, and the dialog box we defined pops up:
, the test is over. We completely broke away from VSwith interfaceIDE and generated a custom dialog box. Isn’t it amazing? There should be Xiao Yueyue's mean expression here. . .
The above is the detailed content of Win32 SDK Basics (2) Detailed explanation of the cl.exe and link.exe compilation and linking procedures (picture). For more information, please follow other related articles on the PHP Chinese website!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

Windows 11’s native apps (like File Explorer) and other shell apps use rounded corners and Fluent Design elements (like Acrylic) by default. In addition to rounded corners, another important design feature of Windows 11 is materials like mica, which aligns the background color of apps with the desktop. Mica is similar to acrylic but works slightly differently. As Microsoft describes it, Windows Mica Materials creates "color hierarchy by aligning backgrounds with apps

The new Windows 11 SDK for build 22523 revealed that Microsoft is developing a new blur effect for Windows 11. This effect is called Tabbed, and is in addition to Acrylic and Mica. The new DWMWA_SYSTEMBACKDROP_TYPE in the 22523 SDK, Mica, Acrylic’s public Win32 API and their weird new “tab” mix: pic.twitter.com/dbsu7ZFiIi — It’s All Back (@StartIsBack) December 15, 2021 Available in the following SDK’s Sample application

Antivirus software may sometimes display a warning stating Trojan/win11.casdet rfn on Windows 32 laptops. It indicates that the PC is infected with Trojan malware, causing it to malfunction. Fortunately, there are some possible ways to fix this problem, as explained below. Additionally, you may be interested in our detailed guide on whether cdn.districtm.io is a pop-up/virus/malware or not. What is Trojan/win32.casdet rfn? Trojan/win32.casdet rfn is a severe Trojan virus infection that can overrun the system and kill its processes, making it easy

The difference between win32 and win64 is: 1. win32 refers to the 32-bit environment of the Microsoft Windows operating system, and win64 refers to the 64-bit version of the Microsoft Windows operating system, which is more stable and faster than the 32-bit version; 2. win32 supports up to 2G of memory. win64 must have more than 4G of memory; 3. win64 supports 64-bit processors, but win32 cannot fully support it; 4. win32 pursues simplicity, while win64 pursues performance.

Master the essential skills for secondary development of Java Hikvision SDK Introduction: With the rapid development of information technology, video surveillance systems have been widely used in various fields. As the leading domestic video surveillance solution provider, Hikvision’s products and technologies have always occupied an important position in the market. In order to meet the needs of different projects, Hikvision provides SDK for developers to carry out secondary development. This article will introduce some essential skills for mastering the secondary development of Java Hikvision SDK, and attach corresponding code examples. 1. Understand Hikvision

Back in August 2021, Microsoft promised that OneNote on Windows 10 and Windows 11 would receive a series of major feature updates in the coming months, as the tech giant unifies multiple versions of the note-taking app into a single one. part of the efforts of customers. OneNote has undergone many changes over the past few years. In 2018, when Microsoft really wanted people to use its UWP version of OneNote, the company stopped bundling the original and feature-rich version of OneNote with preinstalled Office apps. Instead, Microsoft has only provided a UWP client and added new features for modern versions. Microsoft later changed

The full name of sdk is "Software Development Kit", which means "software development kit" in Chinese. It is a set of tools provided by manufacturers of hardware platforms, operating systems (OS) or programming languages. SDKs assist software developers in creating applications for specific platforms, systems or programming languages. A basic SDK usually consists of a compiler, debugger, and application programming interface (API), but may also include other content, such as: documentation, libraries, runtime/development environment, testing/analysis tools, network protocols, etc.

The WindowsAppSDK is a set of tools and APIs that developers can use in their Windows applications to provide "consistent" functionality across a variety of devices using Windows 10 (version 1809 and later) and Windows 11. It's really important to understand that it doesn't replace existing application types like .NET or Windows SDK, it just provides a unified API toolset that can be used to complement your existing applications. Today, Microsoft released version 1.2 of Windows App SDK with many new features. The highlight of this release may be third-party developers
