Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

Command line compiling VC program

2025-04-13 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

Shulou(Shulou.com)06/02 Report--

To compile C++ code under the command line, you need to set up the compilation environment, namely, the header file, the library file, and the location of the compiler cl.exe and connector link.exe.

1) in a simple way, open VS05, click Tools, select Visual Studio 2005 Command Prompt, and the compiled environment is already configured.

Test: try typing cl or link (the exe suffix can be omitted). If you can display the command parameters of cl to indicate that the setting is successful, you can start compiling. Failure tip: 'cl' is not an internal or external command, nor is it a runnable program or batch file.

2) find the vcvarsall.bat batch and run it under cmd to configure the compilation environment. In fact, the first way is to call the batch file. The success tips are as follows:

Setting environment for suing Microsoft Visual Studio 2005 z86 tools.

The file is usually located in Program Files\ Microsoft Visual Studio 8\ VC or Program Files (x86)\ Microsoft Visual Studio 8\ VC. You can search using Everything

3) manually add the system variable to the environment variable

Variable name: INCLUDE

Variable value: d:\ Program Files (x86)\ Microsoft Visual Studio 8\ VC\ include;D:\ Program Files

(x86)\ Microsoft Visual Studio 8\ VC\ PlatformSDK\ Include

Variable name: LIB

Variable value: d:\ Program Files (x86)\ Microsoft Visual Studio 8\ VC\ lib;D:\ Program Files

(x86)\ Microsoft Visual Studio 8\ VC\ PlatformSDK\ Lib

Variable name: path

Add the execution path of cl and link: d:\ Program Files (x86)\ Microsoft Visual Studio 8\ VC\ bin;D:

\ Development\ Common7\ IDE

D:\ Development\ Common7\ IDE is configured to avoid prompting that the mspdb80.dll file cannot be found

4) manually specify the compiled include header file and the linked LIB

-I specify header file

Example:

Cl.exe main.cpp-/ I "D:\ Program Files (x86)\ Microsoft Visual Studio 8\ VC\ include"

Kernel32.lib advapi32.lib user32.lib

In this case, you should also specify the specific directory where kernel32.lib is located!

Note:

1) after cl.exe compilation is completed, link.exe is automatically called to link

2) the list of lib library files for the cl.exe parameter is passed to link.exe for use

Here are some simple compilation parameters:

/ c: compile only, do not link

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 288

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Servers

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report