动态库 DLL 封装二:dll封装方法

例:我新建的工程是,带lib的MFC规则的DLL

主要有三个文件需要写东西 ( .h /  .cpp  /  .def

示例:

// a.h

......


#ifdef __cplusplus
extern "C" {
#endif


/*
* 初始化人脸库
* return 0:成功;-1:失败
*/
long __stdcall FACE_Init();



#ifdef __cplusplus
}
#endif
// a.cpp

// 初始化
long __stdcall FACE_Init()
{
    LOG(INFO) << "FACE_Init";

    if (ZZInitFaceMgr())
    {
        LOG(INFO) << "init success";
        return 0;
    }
    LOG(INFO) << "init fail";
    return -1;
}
// a.def

; a.def : 声明 DLL 的模块参数。

LIBRARY

EXPORTS
    ; 此处可以是显式导出
    FACE_Init                ; 初始化
原文地址:https://www.cnblogs.com/shiyixirui/p/15330400.html