• 多个类的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();  
  • 相关阅读:
    mvc 在ii7上发布时遇到的问题只解决
    @Html.Raw 显示Html的标签
    补发————grid布局
    补发————DOM与BOM
    web实验博客3.css-position
    web专业课学习及往后方向发展
    bom&dom
    网格代码
    简单用户注册表单
    自我介绍
  • 原文地址:https://www.cnblogs.com/lidabo/p/7372221.html
Copyright © 2020-2023  润新知