基本设置:
1. 解压vc71.zip到c:/
2. 在vc71目录中建立两个新的.bat文件:
clean.bat --->
SET MSVCDir=c:/vc71
SET VC_TOOL_PATH=%MSVCDir%/bin
SET 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 %1
nmake clean
make.bat --->
SET MSVCDir=c:/vc71
SET VC_TOOL_PATH=%MSVCDir%/bin
SET 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 %1
nmake
3. 打开UltraEdit
Advanced->Tool Configuration
4. 设置第一个Config
Command line-->选择 c:/vc71/clean.bat %P
working directory--->选择 c:/vc71
menu item name: clean
5. 设置
Output to List Box和Capture Output
6. 点击 insert,这样就创建乐一个新的tool button了
7. 重复4-6,只是把执行文件名改为make.bat,item name改为make
测试:
1 .建立一个新文件夹,在文件夹中创建makefile文件
makefile --->
# This is a MAKEFILE for Microsoft's NMAKE
# extension for object files
O = obj
# commands
CC = cl
# The places to look for include files (in order).
INCL = -I. -I$(INCLUDE)
# Normal C flags.
CFLAGS = /EHsc -W3 $(INCL) -nologo -c
LFLAGS =
# 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.cpp
clean:
del hunter.exe *.$(O)
2. 创建三个测试文件:
test.cpp --->
#include "extern_cpp1.h"
int main()
{
CUser hunter(10040);
hunter.setNickName("haha");
CUser xiaojie(hunter.getUserID());
std::cout << hunter.getUserID() << std::endl;
return 0;
}
extern_cpp1.h --->
#ifndef CUSER_H
#define CUSER_H
#include <iostream>
#include <string>
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 "extern_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. 用ultraedit打开其中一个文件,然后选择
Advanced->make
在下方的listbox中就可以看到make的结果了
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;
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.cpp
test.cpp
cl /EHsc -W3 -I. -Ic:/vc71/INCLUDE;c:/vc71/win32/Include;c:/vc71/INCLUDE/sys; -nologo -c extern_cpp1.cpp
extern_cpp1.cpp
link @hunter.lnk
Microsoft (R) Incremental Linker Version 7.10.2215.1
Copyright (C) Microsoft Corporation. All rights reserved.
test.obj extern_cpp1.obj
/out:hunter.exe