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.
     

  • 相关阅读:
    修改mysql root账户登录密码
    taglib的uri问题
    encoding/path可能引起无数奇怪的问题
    查看JSTL的doc解决问题
    matlab 读取nc
    matlab fread
    用matlab将nc数据读出来,写成二进制文件,然后用grads画图
    matlab 三维绘制
    flex label 换行
    Struts2的使用以及Spring整合Struts2
  • 原文地址:https://www.cnblogs.com/rogerroddick/p/2886705.html
Copyright © 2011-2022 走看看