美文网首页
简单的生成DLL的步骤

简单的生成DLL的步骤

作者: 7bfedbe4863a | 来源:发表于2018-01-03 23:49 被阅读0次

    1.新建项目:
    新建-->项目-->Win32控制台-->选择DLL、空项目。
    2.创建.h文件

    //MyDll.h
    #ifndef _MYDLL_H_
    #define _MYDLL_H_
    
    extern "C"{
    #ifdef _DLL_SAMPLE
    #define DLL_SAMPLE_API __declspec(dllexport)
    #else
    #define DLL_SAMPLE_API __declspec(dllimport)
    #endif
    
        int a = 0;
        DLL_SAMPLE_API void TestDll(int);
    
    #undef  DLL_SAMPLE_API
    }
    #endif
    

    3.创建.cpp文件

    //MyDll.cpp
    #include <iostream>
    #include "MyDll.h"
    
    using namespace std;
    
    void TestDll(int m)
    {
        cout<<"Test Dll "<<m<<" a="<<a<<endl;
    }
    

    4.点击生成。
    在Debug中会生成项目名.dll和.lib文件。

    相关文章

      网友评论

          本文标题:简单的生成DLL的步骤

          本文链接:https://www.haomeiwen.com/subject/owrlnxtx.html