| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 592 人关注过本帖
标题:dll的问题
只看楼主 加入收藏
ylof1986
Rank: 2
等 级:论坛游民
帖 子:241
专家分:61
注 册:2008-1-6
结帖率:93.94%
收藏
 问题点数:0 回复次数:3 
dll的问题
谁能给个简单的例子,先编辑个dll和exe,让这个exe调用dll,最好用C编译的
搜索更多相关主题的帖子: dll 
2008-10-02 10:18
netsolo
Rank: 1
等 级:新手上路
帖 子:122
专家分:0
注 册:2008-3-6
收藏
得分:0 
How to create a dll


Here's an example. Cut and paste the following into a file named dllfct.h:

   #ifdef BUILD_DLL
   // the dll exports
   #define EXPORT __declspec(dllexport)
   #else
   // the exe imports
   #define EXPORT __declspec(dllimport)
   #endif

   // function to be imported/exported
   EXPORT void tstfunc (void);
               Cut and paste the following into a file named dllfct.c:

   #include <stdio.h>
   #include "dllfct.h"

   EXPORT void tstfunc (void)
   {
      printf ("Hello\n");
   }
               Cut and paste the following into a file named hello.c:

   #include "dllfct.h"

   int main ()
   {
      tstfunc ();
      return (0);
   }
               To create the dll and an executable that uses it, try the following:

   gcc -c hello.c
   gcc -c -DBUILD_DLL dllfct.c
   gcc -shared -o tst.dll -Wl,--out-implib,libtstdll.a dllfct.o
   gcc -o hello.exe hello.o -L./ -ltstdll
2008-10-02 10:39
vulture
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2008-9-21
收藏
得分:0 
Please don't use GCC in Linux!
Please use VC in Windows!!!
2008-10-02 12:02
随心
Rank: 16Rank: 16Rank: 16Rank: 16
等 级:版主
威 望:12
帖 子:2577
专家分:250
注 册:2007-8-12
收藏
得分:0 
有静态加载的,有动态加载的,自己看书吧,书上都有

天之道,利而不害。圣人之道,为而不争。信言不美,美言不信。善者不辩,辩者不善。知者不博,博者不知。
2008-10-02 12:25
快速回复:dll的问题
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.010868 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved