Windows简易动态库制作方式
2016-02-01 15:20
309 查看
(初步,建立两个空工程)
第一步:
新建 Window32 控制台应用程序,选择空项目。添加文件 DyTest.cpp。
添加测试内容:
#include <stdio.h>
int main()
{
printf("DyTest \n");
}
输出内容 DyTest。
第一步:
新建 Window32 控制台应用程序,选择空项目。添加文件 UseDy.cpp。
添加测试内容:
#include <stdio.h>
int main()
{
printf("UseDy \n");
}
输出内容 UseDy。
(变换,DyTest 为动态库,UseDy 为执行库)
第一步:DyTest 为动态库制作
1) 设置 DyTest 项目,配置类型 dll 动态库
2) 添加输出 def 文件
{
LIBRARY
Run
}
3)提供头接口 DyTest.h
int __declspec(dllexport) Fun();
4) 修改DyTest.cpp 内容为
#include <stdio.h>
void RunTest();
int __declspec(dllexport) Fun()
{
RunTest();
return 0;
}
void RunTest()
{
printf("DyTest\n");
}
第二步:UseDy 为执行库执行
1) 项目添加 DyTest.h 文件
2) 在UseDy.cpp 中添加
#include <stdio.h>
#include "DyTest.h"
#pragma comment(lib,"DyTest.lib")
int main()
{
Fun();
getchar();
}
第三步:
设置编译时连接地址
VC++ 目录, 1) 可执行文件目录,为 E:\MyPro\DyTest\Debug;$(ExecutablePath)
2) 库目录,为 E:\MyPro\DyTest\Debug;$(LibraryPath)
第一步:
新建 Window32 控制台应用程序,选择空项目。添加文件 DyTest.cpp。
添加测试内容:
#include <stdio.h>
int main()
{
printf("DyTest \n");
}
输出内容 DyTest。
第一步:
新建 Window32 控制台应用程序,选择空项目。添加文件 UseDy.cpp。
添加测试内容:
#include <stdio.h>
int main()
{
printf("UseDy \n");
}
输出内容 UseDy。
(变换,DyTest 为动态库,UseDy 为执行库)
第一步:DyTest 为动态库制作
1) 设置 DyTest 项目,配置类型 dll 动态库
2) 添加输出 def 文件
{
LIBRARY
Run
}
3)提供头接口 DyTest.h
int __declspec(dllexport) Fun();
4) 修改DyTest.cpp 内容为
#include <stdio.h>
void RunTest();
int __declspec(dllexport) Fun()
{
RunTest();
return 0;
}
void RunTest()
{
printf("DyTest\n");
}
第二步:UseDy 为执行库执行
1) 项目添加 DyTest.h 文件
2) 在UseDy.cpp 中添加
#include <stdio.h>
#include "DyTest.h"
#pragma comment(lib,"DyTest.lib")
int main()
{
Fun();
getchar();
}
第三步:
设置编译时连接地址
VC++ 目录, 1) 可执行文件目录,为 E:\MyPro\DyTest\Debug;$(ExecutablePath)
2) 库目录,为 E:\MyPro\DyTest\Debug;$(LibraryPath)
相关文章推荐
- 10 个免费的网络监控工具(转)
- Hbase0.96源码之HMaster(一)
- 无需第三方软件,在 Yosemite 下给 iOS 设备轻松录屏
- navicat for oracle 破解版
- AngularJS自动表单验证
- Openssl Installation in Window
- u盘安装win7旗舰版系统 图文教程
- Codeforces Round #341 (Div. 2) E. Wet Shark and Blocks(dp + 矩阵快速幂)
- objective-zip解压带密码的文件
- JVM源码分析之堆外内存完全解读
- UVA 10557 XYZZY
- Xcode7 使用NSURLSession发送HTTP请求的问题
- rpm包相关操作
- Master Nginx(1) - Installing Nginx and Third-Party Modules
- MySql数据库增删改查示例
- c++特性:static_assert
- SSZipArchive使用详解
- POJ 1511 链式前向星+SPFA
- shell中if多重条件
- Oracle Essbase入门系列(四)