创建DLL [英] Creating DLLs

查看:91
本文介绍了创建DLL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

Hi Banfa也是Everbody,

我非常乐意帮助你们。


请对我来说真的很紧急。


问题

我的项目中有两个模块1)CMBEDIT 2)SYNTHESIS_TOOL


我有这些文件之间的共同点这两个模块

i)ct.h

ii)ct.cpp

iii)route.h

iv )route.cpp

v)basemolecule.h

vi)basemolecule.cpp


否我必须创建dll(DYnamic Link)库)它将充当这些常见文件的存储库。


当我执行CMBEDIT时,它应该调用(dll)并使用这些文件,反之亦然当我执行SYNTHESIS_TOOL时,它应该调用相同的(dll)并使用这些文件。


我是dll区域的新手,这是我的第一次体验...请写下完整的说明那发生了。我正在使用Visual Studio。我的系统上的NET 2003。


请尽快回复我。这真的很紧急。


等待回复。

Hi Banfa also Everbody,
I''m extremely in help with you guys.

Please Please it is really urgent to me.

Problem
I have two modules in my project 1) CMBEDIT 2) SYNTHESIS_TOOL

I have these files common between these two modules
i) ct.h
ii) ct.cpp
iii) route.h
iv) route.cpp
v) basemolecule.h
vi) basemolecule.cpp

No I have to create dll( DYnamic Link Library ) which will act as a repository for those common files.

When I execute CMBEDIT, it should call (dll) and make use of those files, vice versa When I execute SYNTHESIS_TOOL, it should call same (dll) and make use of those files.

I''m a newbie in dll areas and this is my first experience...PLease write the complete instructions to make that happen. I''m using Visual Studio. NET 2003 on my system.

Please Please reply me as soon as possible. It is really urgent.

Waiting for a reply.

推荐答案

这就是这样的事情(不幸的是我有权访问)到Visual Studio 6和Visual Studio 2005但不是2003 .net所以你必须解释我所说的内容)


在Visual Studio中


1.启动一个新项目(文件 - > New ...和选项卡中的selct项目)


2.选择WIN32动态链接库,填写项目名称等点击确定


3.当被问到选择导出一些符号的DLL时


4.它将创建一个cpp文件DLLMain加上一些示例符号(一个基本的calss和一个函数的int)加上一个头文件(加上无处不在的stdafx.cpp和stdafx.h用于预编译的头文件)


5.不要删除DLLMain但是一旦你理解了它就可以去做示例。


6.将源文件包含到项目中声明符号是由示例中的头文件中的程序访问。这里重要的一点是,在编译DLL时,必须使用


__declspec(dllexport)


声明要导出的符号





__declspec(dllimport)


编译程序时。


7.构建你的DLL。这将导致.DLL文件和.LIB文件


8.在您的程序中包含DLL头和与.LIB文件的链接


9.运行程序时,请确保DLL文件与EXE位于同一目录中,或者它位于路径中。
Right it goes something like this (unfortunately I have access to Visual Studio 6 and Visual Studio 2005 but not 2003 .net so you will have to interpret what I say inteligently)

In Visual Studio

1. Start a new project (File -> New... and selct projects from the Tabs)

2. Select a WIN32 Dynamic Link Library, fillin project name etc. and hit OK

3. When asked select "a DLL that exports some symbols"

4. It will create a cpp file with a DLLMain plus some example symbols (an int a basic calss and a function) plus a header file (plus the ubiquitous stdafx.cpp and stdafx.h for precompiled headers)

5. Do not delete the DLLMain but the example stuff can go once you have understood it.

6. Include you source files into the project declare symbols to be accessed by the program in the header file following the examples. The important point here is that a symbol that is to be exported must be declared with

__declspec(dllexport)

when compiling the DLL

and

__declspec(dllimport)

when compiling the program.

7. Build your DLL. This will result in a .DLL file and a .LIB file

8. In your program include the DLL header and link with the .LIB file

9. When you run your program make sure that the DLL file is in the same directory as the EXE or that it is in the path.



这就是这样的事情(不幸的是我可以访问Visual Studio 6和Visual Studio 2005而不是2003 .net所以你必须解释我所说的内容)


在Visual Studio中


1.开始一个新项目(文件 - > New ...和选项卡中的selct项目)


2.选择一个WIN32动态链接库,填写项目名称等,然后点击OK


3.当被问到选择导出一些符号的DLL时


4.它将创建一个带有DLLMain的cpp文件加上一些示例符号(一个基本的calss和一个函数的int)加上一个头文件(加上无处不在的stda) fx.cpp和stdafx.h用于预编译的头文件)


5.不要删除DLLMain,但是一旦你理解了它就可以使用示例内容。


6.将源文件包含在项目声明符号中,以便程序在示例后面的头文件中访问这些符号。这里重要的一点是,在编译DLL时,必须使用


__declspec(dllexport)


声明要导出的符号





__declspec(dllimport)


编译程序时。


7.构建你的DLL。这将导致.DLL文件和.LIB文件


8.在您的程序中包含DLL头和与.LIB文件的链接


9.运行程序时,请确保DLL文件与EXE位于同一目录中,或者位于路径中。
Right it goes something like this (unfortunately I have access to Visual Studio 6 and Visual Studio 2005 but not 2003 .net so you will have to interpret what I say inteligently)

In Visual Studio

1. Start a new project (File -> New... and selct projects from the Tabs)

2. Select a WIN32 Dynamic Link Library, fillin project name etc. and hit OK

3. When asked select "a DLL that exports some symbols"

4. It will create a cpp file with a DLLMain plus some example symbols (an int a basic calss and a function) plus a header file (plus the ubiquitous stdafx.cpp and stdafx.h for precompiled headers)

5. Do not delete the DLLMain but the example stuff can go once you have understood it.

6. Include you source files into the project declare symbols to be accessed by the program in the header file following the examples. The important point here is that a symbol that is to be exported must be declared with

__declspec(dllexport)

when compiling the DLL

and

__declspec(dllimport)

when compiling the program.

7. Build your DLL. This will result in a .DLL file and a .LIB file

8. In your program include the DLL header and link with the .LIB file

9. When you run your program make sure that the DLL file is in the same directory as the EXE or that it is in the path.



您好Banfa,

我能跟随直到第5步并获得这些文件

1)myDll.h

2)stdafx.h

3)myDll.cpp

4)stdafx.cpp

myDll.cpp的输出似乎是这样的

Hi Banfa,
Thankx for your immediate reply...
I''m able to follow till steps 5 and got these files
1) myDll.h
2) stdafx.h
3) myDll.cpp
4) stdafx.cpp
The output of myDll.cpp seems to be like this

展开 | 选择 | Wrap | 行号


第6步


在你的orignal帖子中你提到想要放下面的文件


i)ct。 h $>
ii)ct.cpp

iii)route.h

i v)route.cpp

v)basemolecule.h

vi)basemolecule.cpp


进入DLL。这些函数包含一些符号(即函数和/或变量。


DLL的单个标题是正常的(虽然我理解为每个C文件都有一个标题的概念)在一个项目中)所以我说


将源文件包含到项目中,在示例后面的头文件中声明要由程序访问的符号。这里重点是必须使用


声明要导出的符号(表示无论如何:D),您应该将上面列出的源文件包含到DLL项目中。然后移动从上面列出的标题到DLL标题的符号声明也确保它们在下面列出的正确限定符声明它们。


__declspec(dllexport)


编译DLL时





__declspec(dllimport)


编译时该计划。



我那更清楚了吗?
Step 6

In your orignal post you mention wanting to put the following files

i) ct.h
ii) ct.cpp
iii) route.h
iv) route.cpp
v) basemolecule.h
vi) basemolecule.cpp

Into the DLL. These functions contain some symbols (i.e. functions and/or variables.

It is normal to have a single header for a DLL (although i understand the concept of having a header for every C file in a project) so I said

"Include you source files into the project declare symbols to be accessed by the program in the header file following the examples. The important point here is that a symbol that is to be exported must be declared with"

indicating (well trying to anyway :D) that you should include the source files listed above into your DLL project. Then move the symbol declarations from the headers listed above to the DLL header also making sure that they where declared with the correct qualifier listed below.

__declspec(dllexport)

when compiling the DLL

and

__declspec(dllimport)

when compiling the program.



Is that clearer?


这篇关于创建DLL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆