首页 > 编程语言 > 详细

GCC C语言 DLL范例,含源码

时间:2017-10-13 12:09:19      阅读:298      评论:0      收藏:0      [点我收藏+]

作者:小白救星
编译: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\n", 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

 

GCC C语言 DLL范例,含源码

原文:http://www.cnblogs.com/bdccloudy/p/7660261.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!