zoukankan      html  css  js  c++  java
  • GCC C语言 DLL范例,含源码

    作者:小白救星
    编译:gcc -c -DBUILDING_HZ_DLL1 hzdll1.c
               gcc -shared -o hzdll1.dll hzdll1.o -Wl,--kill-at,--out-implib,hzdll1.a
               或:gcc -shared -o hzdll1.dll hzdll1.o -Wl,--kill-at,--out-implib,hzdll1.lib
    查看dll中的函数:dumpbin -exports hzdll1.dll

    hzdll1.c

    #include <stdio.h>
    #include "hzdll1.h"
    
    __stdcall void hello(const char *s)
    //void hello(const char *s)
    {
            printf("Hello %s
    ", s);
    }
    
    int Double(int x)
    {
            return 2 * x;
    }

    hzdll1.h

    #ifndef HZ_DLL1_H
    #define HZ_DLL1_H
    
    #ifdef __cplusplus
    extern "C" {
    #endif
    
    #ifdef BUILDING_HZ_DLL1
    #define HZ_DLL1 __declspec(dllexport)
    #else
    #define HZ_DLL1 __declspec(dllimport)
    #endif
    
    void __stdcall HZ_DLL1 hello(const char *s);
    //void HZ_DLL1 hello(const char *s);
    
    int HZ_DLL1 Double(int x);
    
    #ifdef __cplusplus
    }
    #endif
    
    #endif  // HZ_DLL1_H
  • 相关阅读:
    if..endif 语法
    WordPress程序流程分析
    php锁表
    jQuery入门必须掌握的一些API
    集合栈
    回文链表
    链式A+B
    链表分割
    访问单个节点的删除
    链表中倒数第k个结点
  • 原文地址:https://www.cnblogs.com/bdccloudy/p/7660261.html
Copyright © 2011-2022 走看看