VS2012创建静态库(Win32)
来源:互联网 发布:软件测试 培训学校 编辑:程序博客网 时间:2024/06/05 10:18
1、打开VS,新建一个Win32项目,勾选“静态库”选项:
2、添加一个简单的计算类MyMath:
3、向类中添加变量及函数,详情如下:
MyMath.h
#pragma onceclass CMyMath{public:CMyMath(void);~CMyMath(void);int Add(int a, int b);int m_a;};extern int g_sum;extern int Mult(int a, int b);
MyMath.cpp
#include "stdafx.h"#include "MyMath.h"int g_sum = 0;int Mult(int a, int b){return a * b;}CMyMath::CMyMath(void): m_a(0){}CMyMath::~CMyMath(void){}int CMyMath::Add(int a, int b){return a + b;}
4、生成项目,产生一个.lib文件:
5、OK,一个静态库已经生成了,接下来创建一个项目用于测试:
6、在测试工程中,配置头文件和库文件:
7、测试代码:
// static_lib_test.cpp : 定义控制台应用程序的入口点。//#include "stdafx.h"#include "MyMath.h"int _tmain(int argc, _TCHAR* argv[]){CMyMath myMath;int a = myMath.Add(3, 4);int b = Mult(3, 4);int c = g_sum;int d = myMath.m_a;printf("%d %d %d %d \n", a, b, c, d);return 0;}
8、结果:
0 0
- VS2012创建静态库(Win32)
- VS2012创建动态库DLL(Win32)
- VS2012 下创建win32应用程序(不是win32 console 程序)
- VC++:创建,调用Win32静态链接库
- VS2012创建DLL动态库
- VS2012引入静态和动态链接库
- vs2012编译使用lua 5.2静态库
- vs2012编译使用lua 5.2静态库
- [Cocos2D-X]在windows8下:VS2012+Cocos2D-X-2.1.4+cygwin创建win32项目
- win32下vs2012 编译 libssh2
- vs2012 编译vtk5.8.0 win32
- VS2012 win32控制台调试总结
- Win32开发 - VS2012常用插件
- VS2012静态链接设置
- VS2012静态链接设置
- VS2012静态链接lua
- vs2012 静态编译
- 编译并链接pthreads-win32静态库
- 16 输入一颗二元树,从上往下按层打印树的每个结点,同一层中按照从左往右的顺序打印。
- Selective Search for Object Recognition
- VS2010中VAssistX破解办法
- Apache Commons Configuration 读取配置信息
- 17 在一个字符串中找到第一个只出现一次的字符
- VS2012创建静态库(Win32)
- HDFS LocalResource
- Ubuntu 12.04 AFTR 配置
- Oracle中EXECUTE IMMEDIATE的使用技巧
- UINavigationController 直接返回到第一级目录
- Android再曝重大漏洞!请及时更新你的系统
- iOS 7.0 设置长文本UILabel高度
- 教育数据挖掘
- java笔记