zoukankan      html  css  js  c++  java
  • How to create dll on windows

    Preparation

    Using visual studio to create dll binary as your project in order to reuse code conveniently.

    1. Install visual studio which includes visual c++

    2. Create a new project (File/Create/Project) and choose visual c++ template on left panel and choose win32 console application. Then input the project name.

    3. Choose DLL in application type and keep other settings as default.

    4. If you want to export the public interfaces as .lib file, set configuration properties/Linker/Advanced/Import Library as $(outdir)$(targetname).lib.

    5. Define some public interfaces and then build it. Then you will see the lib, dll file is under the same folder.

    DLL implement

    for exporting global functions, use __declspec keyword. With using this dllexport way, the method signature will be listed in the .lilb file.

    __declspec(dllexport) int Add (int lhs, int rhs)
    {
    return lhs + rhs;
    }
     

    Invoking DLL

    include the header file with the method signature
    #include "../ItemSync/ItemSyncDll.h"
    #pragma comment (lib, "ItemSync.lib")
    int main()
    {
    int ret = Add(1,2);
    return 0;
    }
    Also you could put the lib under configuration properties/Linker/Input/Additional Dependencies. In thay way, the pragma comment could be ignored.
     

  • 相关阅读:
    Servlet概述
    JAVA WEB开发环境与搭建
    Java scirpt简介
    用HTML+CSS编写一个计科院网站首页的静态网页
    CSS样式
    HTML简介
    Web服务器的原理
    静态网页与动态网页的区别
    debugger工具的使用以及调试
    javascript页面刷新的几种方法
  • 原文地址:https://www.cnblogs.com/rogerroddick/p/2886705.html
Copyright © 2011-2022 走看看