zoukankan      html  css  js  c++  java
  • 多个类的DLL封装及调用

    [cpp] view plaincopy
     
     
    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(或写全路径:"..debugfacedll.lib")

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

    [cpp] view plaincopy
     
     
    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 plaincopy
     
     
    1. #pragma  comment(lib,"facedll.lib")  
    2. #pragma  comment(lib,"heartdll.lib")  
    之后程序中就可以直接使用封装成DLL的类了:
    [cpp] view plaincopy
     
     
    1. HRMeasure *hrMea=new HRMeasure();  
  • 相关阅读:
    设计模式之原型模式
    设计模式之建造者模式
    一个工厂还能写出花来?
    一个单例还能写出花来?
    python基础之条件循环语句
    python基础之七种运算符
    python基础之五大标准数据类型
    node.js express mvc轻量级框架实践
    js Date() 浏览器兼容问题解决
    js 倒计时(服务器时间同步)
  • 原文地址:https://www.cnblogs.com/lidabo/p/7372221.html
Copyright © 2011-2022 走看看