Compile Windows programs with command line

xiaoxiao2021-03-06  73

basic settings:

1. Unzip VC71.ZIP to C: / 2. Build two new .bat files in the VC71 directory:

Clean.bat ---> set msvcdir = c: / vc71set vc_tool_path =% msvcdir% / binset path =% vc_tool_path%;% path% set include =% msvcdir% / include;% msvcdir% / win32 / include;% msvcdir% / Include / sys;% include% set lib =% msvcdir% / lib;% msvcdir% / Win32 / lib;% lib%

CD% 1nmake Clean

Make.bat ---> set msvcdir = c: / vc71set vc_tool_path =% msvcdir% / binset path =% vc_tool_path%;% PATH% SET include =% msvcdir% / include;% msvcdir% / win32 / include;% msvcdir% / Include / sys;% include% set lib =% msvcdir% / lib;% msvcdir% / Win32 / lib;% lib%

CD% 1nmake

3. Open Ultraeditadvanced-> Tool Configuration

4. Set the first configcommand line -> Select C: /VC71/CLEAN.BAT% PWORKING DIRECTORY ---> Select C: / VC71MENU Item Name: Clean

5. Set Output to List Box and Capture Output

6. Click Insert to create a new Tool Button.

7. Repeat 4-6, just change the executive file name to make.bat, item name change to MAKE

Test: 1. Create a new folder, create a Makefile file in the folder

Makefile ---> # this is a makefile for microsoft's nmake

# extension for Object Fileso = OBJ

# Commandscc = CL

# The Places To Look for Include Files (in Order) .incl = -i. -I $ (Include)

# Normal C Flags.cflags = / EHSC -W3 $ (INCL) - NOLOGO-CLFLAGS =

# The location of the demo source directory.testdir = ./#

All: hunter.exe

Hunter.exe: Test. $ (o) extern_cpp1. $ (o) link @ << Hunter.Lnk $ (LFLAGS) Test. $ (o) extern_cpp1. $ (o) / out: $ @ << nokeep

Test. $ (o): Test.cpp EXTERN_CPP1.H $ (CC) $ (cflags) Test.cpp

EXTERN_CPP1. $ (o): EXTERN_CPP1.CPP EXTERN_CPP1.H $ (CC) $ (cflags) extern_cpp1.cpp1

Clean: del hunter.exe *. $ (o)

2. Create three test files: Test.cpp ---> # include "extern_cpp1.h"

INT main () {CUSER HUNTER (10040); Hunter.setnickName ("Ha"); cuser.getuserid ()); std :: cout << hunter.getuserid () << std :: endl; return 0 ;} extern_cpp1.h ---> # IFNDEF CUSER_H # Define Cuser_H

#include #include

Using namespace std;

class CUser {private: CUser (CUser &) {}; operator = (CUser & rhs) {}; int m_iUserID; string m_sNickName; public: CUser (int iUserID) {m_iUserID = iUserID; cout << "some one create a new class" << endl;}; bool setnickname (const char * psnickname); inline int getUserid () {return m_iUserid;};

#ENDIF

EXTERN_CPP1.CPP ---> # include "external_cpp1.h"

Bool Cuser :: SetNickName (const char * psnickname) {if (psnickname == null) Return False; if (psnickname [0] == 0) Return False; m_snickname = psnickname; return true;}

3. Open one of the files with UltraEdit, then select Advanced-> Make

You can see the result of Make in the lower listbox.

C: / vc71 / test> set msvcdir = c: / vc71

C: / VC71 / TEST> SET VC_TOOL_PATH = C: / VC71 / BIN

C: / VC71 / TEST> SET PATH = C: / VC71 / BIN; C: / Program Files / ThinkPad / Utilities; C: / Windows / System32; C: / Windows; C: / Windows / System32 / WBEM; C: / Program Files / ATI TECHNOLOGIES / ATI Control Panel; C: / Program Files / PC-DOCTOR for Windows / Services; C: / Program Files / UltraEdit

C: / VC71 / TEST> SET INCLUDE = C: / VC71 / include; C: / VC71 / WIN32 / INCLUDE; C: / VC71 / INCLUDE / SYS

C: / VC71 / TEST> SET LIB = C: / VC71 / LIB; C: / VC71 / WIN32 / LIB Download Adobe Reader

C: / VC71 / TEST> CD C: / Docume ~ 1 / IBM / MYDOCU ~ 1 / Source / XML / TEST /

C: / VC71 / TEST> NMAKE

Microsoft (R) Program Maintenance Utility Version 7.10.2215.1 Copyright (c) Microsoft Corporation. All Rights Reserved.

CL / EHSC -W3 -I. -IC: / vc71 / include; c: / vc71 / win32 / include; c: / vc71 / include / sys; -nologo -c test.cpptest.cpp cl / ehssc -w3 -i ., C: / vc71 / win32 / include; c: / vc71 / include / sys; -nologo -c extern_cpp1.cppextern_cpp1.cpp1.cppextern_cpp1.cpp1.cppextern_cpp1.cpp1.cppextern_cpp1.cpp1.cppPPPEXTERN_CPP1.CPPLINK @ Hunter.LnkMicrosoft (R) Incremental Linker Version 7.10.2215.1 Copyright (c) Microsoft Corporation. All rights reserved.test.obj extern_cpp1.obj /out:hunter.exe

转载请注明原文地址:https://www.9cbs.com/read-121225.html

New Post(0)