| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1263 人关注过本帖
标题:在VC++中怎么把自己写的C++代码生成.dll文件
只看楼主 加入收藏
fangfangff
Rank: 1
等 级:新手上路
威 望:2
帖 子:479
专家分:0
注 册:2006-12-22
收藏
 问题点数:0 回复次数:8 
在VC++中怎么把自己写的C++代码生成.dll文件
在VC++中怎么把自己写的C++代码生成.dll文件,
在该怎么建工程呢??还有文件也怎么建呢??
建这些的步骤是怎么样的啊??可以讲解一下吗??
请各位高手帮帮忙哈!!
在此先谢谢了!
谢谢哈!!
搜索更多相关主题的帖子: dll 文件 代码 
2007-09-16 21:11
雨中飞燕
Rank: 3Rank: 3
等 级:禁止访问
威 望:8
帖 子:2200
专家分:0
注 册:2007-8-9
收藏
得分:0 
建立一个Dll的工程



by 雨中飞燕 QQ:78803110 QQ讨论群:5305909

[url=http://bbs.bc-cn.net/viewthread.php?tid=163571]请大家不要用TC来学习C语言,点击此处查看原因[/url]
[url=http://bbs.bc-cn.net/viewthread.php?tid=162918]C++编写的Windows界面游戏[/url]
[url=http://yzfy.org/]C/C++算法习题(OnlineJudge):[/url] http://yzfy.org/
2007-09-16 21:20
fangfangff
Rank: 1
等 级:新手上路
威 望:2
帖 子:479
专家分:0
注 册:2006-12-22
收藏
得分:0 

大体的过程是怎么样的啊???
我也不太明白怎么建立啊!!!
谢谢你哈!!


千里冰封---My Love 尽管相隔千里 , 依然拥有冰封
2007-09-16 21:33
HJin
Rank: 6Rank: 6
等 级:贵宾
威 望:27
帖 子:401
专家分:0
注 册:2007-6-9
收藏
得分:0 
回复:(fangfangff)在VC++中怎么把自己写的C++代码生...

I will explain what you need to do on a windows system.

Step 1: (file name is helloDLL.c)

程序代码:

/**
File: helloDLL.c

To make a .DLL file, compile it with

cl /LD helloDLL.c

The above is for MS complier. You may
complier's command may be different.
*/

#include <stdio.h>

__declspec(dllexport) void hello_world()
{
printf(\"Hello, world.\n\");
}



run cl /LD helloDLL.c to make the DLL and Lib;

Step 2: (file name is callDll.c)
程序代码:

// cl callDll.c

#include <windows.h>

int main()
{
HINSTANCE hLib;
void (*funcPointer)(void); // funcPointer can be named anything

hLib = LoadLibrary(\"helloDLL.DLL\");
funcPointer = (void (*)(void))GetProcAddress(hLib, \"hello_world\");
funcPointer();

return 0;
}


run cl callDll.c to make a .exe file --- you can run the .exe file after compilation. Here we dynamically linked against library helloDLL.DLL;

Step3 (filename is callLib.c)

// compile by command: cl callLib.c helloDll.lib

void hello_world();

int main()
{
hello_world();

return 0;
}



run cl callLib.c helloDll.lib to make .exe file --- you can run the .exe file after compilation. Here we statically linked against the library file helloDll.lib.

The above is MS stuff: windows system with MS VC. If you are using Linux/Unix or the complier is gcc/g++, you need to make some changes.

HJin




I am working on a system which has no Chinese input. Please don\'t blame me for typing English.
2007-09-16 23:02
fangfangff
Rank: 1
等 级:新手上路
威 望:2
帖 子:479
专家分:0
注 册:2006-12-22
收藏
得分:0 
谢谢你哈!!
你是不是从国外来的呢??
怎么都是英文的啊
这个我看得不懂
我叫别人帮忙翻译一下就可以了
谢谢哈!!

千里冰封---My Love 尽管相隔千里 , 依然拥有冰封
2007-09-17 12:56
冰的热度
Rank: 2
等 级:禁止访问
威 望:5
帖 子:404
专家分:0
注 册:2006-12-2
收藏
得分:0 

VC++6.0的向导选项卡里有.MFC AppWizard(dll)和Win32 Dynamic-Link Library

用这两个来建


科学是永恒之迷...... 我的博客http://blog..cn/u/1267727974 阅读我的blog,懂与不懂都是收获!
2007-09-17 18:23
fangfangff
Rank: 1
等 级:新手上路
威 望:2
帖 子:479
专家分:0
注 册:2006-12-22
收藏
得分:0 
回复:(冰的热度)VC++6.0的向导选项卡里有.MFC AppW...

这样的话怎么建呢??
是不是直接建了就可以了啊
有没有什么特殊的过程和设置的吗???

千里冰封---My Love 尽管相隔千里 , 依然拥有冰封
2007-09-17 21:33
雨中飞燕
Rank: 3Rank: 3
等 级:禁止访问
威 望:8
帖 子:2200
专家分:0
注 册:2007-8-9
收藏
得分:0 
以下是引用fangfangff在2007-9-17 21:33:32的发言:

这样的话怎么建呢??
是不是直接建了就可以了啊
有没有什么特殊的过程和设置的吗???

请问你自己动手试了没有?需要找个人手把手教你吗??
别人不是已经告诉了你建立什么工程吗?
建立个工程都不会自己去试,那你怎么学下去?



by 雨中飞燕 QQ:78803110 QQ讨论群:5305909

[url=http://bbs.bc-cn.net/viewthread.php?tid=163571]请大家不要用TC来学习C语言,点击此处查看原因[/url]
[url=http://bbs.bc-cn.net/viewthread.php?tid=162918]C++编写的Windows界面游戏[/url]
[url=http://yzfy.org/]C/C++算法习题(OnlineJudge):[/url] http://yzfy.org/

2007-09-17 21:42
踏魔狼
Rank: 6Rank: 6
等 级:贵宾
威 望:24
帖 子:1322
专家分:33
注 册:2005-9-22
收藏
得分:0 

呵呵!


=×&D o I p R e E n C g T l X&×=
2007-09-17 21:52
快速回复:在VC++中怎么把自己写的C++代码生成.dll文件
数据加载中...
 
   



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

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