多个类的DLL封装及调用

[cpp]  view plain copy
 
 
  1. #define FaceLIBDLL  
  2.   
  3. #include "stdafx.h"  
  4. #include "facedll.h"  
  5. #include <opencv2/opencv.hpp>  
  6.   
  7. //头文件中函数的实现  
  8. FaceRecognizer::FaceRecognizer()   
  9. {     
  10.   
  11. }   
  12.   
  13. FaceRecognizer::~FaceRecognizer()   
  14. {     
  15.   
  16. }   

生成(Build)工程,在debug文件夹中会生成相应的DLL及LIB文件:facedll.dll   facedll.lib

 

多个类封装DLL

封装好一个类之后,在后面的类可以调用这个类生成的dll,再封装新类的dll。

需要在工程中添加需要引用的头文件,如facedll.h。在debug中拷贝facedll.lib文件。在 Properties->Linker->Input->  Additional Dependecies中添加facedll.lib(或写全路径:"..\debug\facedll.lib")

然后一样的方法再封装新的类就可以了~

 

[cpp]  view plain copy
 
 
  1. #pragma once  
  2. #ifdef HEARTLIBDLL  
  3. #define HEARTAPI _declspec(dllexport)  
  4. #else  
  5. #define HEARTAPI  _declspec(dllimport)  
  6. #endif  
  7.   
  8. #include <opencv2/opencv.hpp>  
  9. #include "facedll.h"  
  10. #include "datadll.h"  
  11.   
  12. class HEARTAPI  HRMeasure  
  13. {  
  14. };  

 

调用DLL

调用需要各个dll的.h、.dll、.lib文件。
将头文件添加到工程中,并#include到需要用的地方。将lib文件拷贝到项目中,并在 Properties->Linker->Input->  Additional Dependecies 中写入:facedll.lib;heartdll.lib。
或者在程序中写入:
[cpp]  view plain copy
 
 
  1. #pragma  comment(lib,"facedll.lib")  
  2. #pragma  comment(lib,"heartdll.lib")  
之后程序中就可以直接使用封装成DLL的类了:
[cpp]  view plain copy
 
 
  1. HRMeasure *hrMea=new HRMeasure();  
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值