如何生成dll

bupo_007 2008-05-21 06:00:05
我用c++写了一个类,想生成dll在c#里调用。不知道怎么生成。
看了msdn都是英文的看不懂,中文的也解释不清楚。
请大家赐教,最好是给个例子~~~
谢谢了
比如:
class Graph
{
private:
int cityNum;//城市的数量

Hnode *h;//头结点数组的指针
ArcNode *a;
public:
Table *table;//标志表
Graph(void);
Graph(int c);
~Graph(void);
void Set(int c);
void ReadG(void);
void AddP(Path p);
void Dijkstra(int start,Time t);
void displayP(int aim);

private:
void Dele(ArcNode *a);
ArcNode * FindVe(ArcNode *a,int city);
int TimeLP(vector<Path> p,Time t);
int MinT(TimeS *ts,int s);
};
这个类要怎么改才能生成dll。还有,这给类还用到了很多别的结构,和类,这些类也要改吗?
生成dll,用不用写main函数呢?
...全文
63 6 打赏 收藏 转发到动态 举报
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
bupo_007 2008-05-24
  • 打赏
  • 举报
回复
非常感谢
试试看
机智的呆呆 2008-05-21
  • 打赏
  • 举报
回复
另外c++的函数调用约定要跟c#一致~~~~~~~
chen_yuan 2008-05-21
  • 打赏
  • 举报
回复

//*.h
#ifdef MYLIBAPI
#define MYLIBAPI extern "C" __declspec(dllexport)
#else
#define MYLIBAPI extern "C" __declspec(dllimport)
#endif

class MYLIBAPI CMyClass // 导出整个类
{
// 类成员
};

//*.cpp
#define MYLIBAPI
#include "*.h"//header file of your defined class
// 函数的实现
...
socrates 2008-05-21
  • 打赏
  • 举报
回复
在用vc建立工程时选Win32 Dynamic-Link Libray就OK了
leelittlelong 2008-05-21
  • 打赏
  • 举报
回复
//*.h
#ifdef MYDLL
#define EXPORT_DLL __declspec( dllexport )
#elseif
#define EXPORT_DLL __declspec( dllimport )
#endif

class EXPORT_DLL CMyClass
{
}

//*.cpp
#define MYDLL
#include "dll.h"//your class header file

bupo_007 2008-05-21
  • 打赏
  • 举报
回复
各位大哥,请伸出援助之手啊~~

64,648

社区成员

发帖
与我相关
我的任务
社区描述
C++ 语言相关问题讨论,技术干货分享,前沿动态等
c++ 技术论坛(原bbs)
社区管理员
  • C++ 语言社区
  • encoderlee
  • paschen
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
  1. 请不要发布与C++技术无关的贴子
  2. 请不要发布与技术无关的招聘、广告的帖子
  3. 请尽可能的描述清楚你的问题,如果涉及到代码请尽可能的格式化一下

试试用AI创作助手写篇文章吧