windows下makefile文件:nmake用法
2010-06-03 17:21
489 查看
1、程序源文件:
如有三个文件:主文件:hello.cpp,类NUM的说明和实现文件:Num.h和Num.cpp,内容如下:
main.cpp:
#include "iostream"
#include "NUM.h"
using namespace std;
int main()
{
cout<<"Hello world"<<endl;
NUM a;
a.Add(1);a.Add(3);a.Add(5);
a.Display();
return 0;
}
NUM.cpp:
#include "iostream"
#include "NUM.h"
using namespace std;
bool NUM::Add(int a)
{
vecArr.push_back(a);
return true;
}
void NUM::Display()
{
for(vector<int>::iterator it = vecArr.begin(); it != vecArr.end(); it )
{
cout<<*it<<'t';
}
return ;
}
NUM.h
#include "vector"
using namespace std;
class NUM
{
public:
bool Add(int a);
void Display();
private:
vector<int> vecArr;
};
2、相应的Makefile文件hello.mk:
all :hello.exe
hello.exe : hello.obj NUM.obj
link hello.obj NUM.obj
hello.obj : Num.h
cl -c hello.cpp
NUM.obj : NUM.h
cl -c NUM.cpp
3、NMake的配置:
为NMake、cl、link运行设置环境变量:在目录《.net安装目录》Microsoft Visual Studio
.NET 2003Common7Tools中找到vsvars32.bat,在当前的dos窗口中运行它,以后在该窗口就能正常使用
NMake、cl、link了
编写makefile文件:按第二步编写makefile文件保存为hello.mk
运行NMake: NMake /f hello.mk
如有三个文件:主文件:hello.cpp,类NUM的说明和实现文件:Num.h和Num.cpp,内容如下:
main.cpp:
#include "iostream"
#include "NUM.h"
using namespace std;
int main()
{
cout<<"Hello world"<<endl;
NUM a;
a.Add(1);a.Add(3);a.Add(5);
a.Display();
return 0;
}
NUM.cpp:
#include "iostream"
#include "NUM.h"
using namespace std;
bool NUM::Add(int a)
{
vecArr.push_back(a);
return true;
}
void NUM::Display()
{
for(vector<int>::iterator it = vecArr.begin(); it != vecArr.end(); it )
{
cout<<*it<<'t';
}
return ;
}
NUM.h
#include "vector"
using namespace std;
class NUM
{
public:
bool Add(int a);
void Display();
private:
vector<int> vecArr;
};
2、相应的Makefile文件hello.mk:
all :hello.exe
hello.exe : hello.obj NUM.obj
link hello.obj NUM.obj
hello.obj : Num.h
cl -c hello.cpp
NUM.obj : NUM.h
cl -c NUM.cpp
3、NMake的配置:
为NMake、cl、link运行设置环境变量:在目录《.net安装目录》Microsoft Visual Studio
.NET 2003Common7Tools中找到vsvars32.bat,在当前的dos窗口中运行它,以后在该窗口就能正常使用
NMake、cl、link了
编写makefile文件:按第二步编写makefile文件保存为hello.mk
运行NMake: NMake /f hello.mk
相关文章推荐
- windows下makefile文件:nmake用法
- VS.net下编写makefile文件--NMAKE用法
- Makefile文件的格式与用法(转)
- Windows下使用MakeFile(Mingw)文件
- nmake命令(windows下的makefile)
- linux与Windows使用编译区别及makefile文件编写
- switch的用法(用到头文件Windows中的MessageBoxA和ShellExecuteA)
- Makefile编译目录下多个文件以及函数wildcard用法
- [转]nmake命令(windows下的makefile)
- ROBOCOPY用法 windows的可靠文件复制
- 在windows里写NMake makefile,编译时遇到的cl.exe command line : error D8003 missing source filename(缺少源文件名)
- nmake命令(windows下的makefile)
- nmake命令(windows下的makefile)
- Windows下使用MakeFile(Mingw)文件
- nmake命令(windows下的makefile)
- Windows 环境下32位汇编语言程序设计 Makefile文件定义
- Windows makefile 多个引用库文件路径配置
- Makefile文件的格式与用法
- makefile文件及VC++自带的Nmake
- windows上cmake与nmake的搭配用法