简体   繁体   English

怎么用dll?

[英]how to use dll?

i have have a program/project in vs2008 that uses a third party static lib. 我在vs2008中有一个使用第三方静态库的程序/项目。 Now, it has come to my attention that i need to offer some api's via a dll. 现在,我注意到我需要通过dll提供一些api。 Apparently a thrid party program will use my dll via the apis i will provide. 显然,一个第三方计划将通过我将提供的api使用我的dll。

Can anyone give me some direction as to what I need to do? 任何人都可以给我一些方向来指导我需要做什么吗? would i need to just create a dll in vs2008 and just copy and paste my method logic in the apis that i provide? 我需要在vs2008中创建一个dll,只需将我的方法逻辑复制并粘贴到我提供的api中吗?

are there any potential issues i need to worry about? 我有什么潜在的问题需要担心吗?

thank you 谢谢

I suggest you check out this MSDN tutorial on creating & using DLLs. 我建议你查看这个关于创建和使用DLL的MSDN教程

There are unfortunately many potential issues to think about. 不幸的是,有许多潜在的问题需要考虑。 A very brief and by no means complete list of the ones that pop in to my head: 一个非常简短的,绝不是完整的列表,列在我脑海中:

  • You need to be aware of potential errors passing CRT objects across DLL boundaries 您需要了解跨DLL边界传递CRT对象潜在错误
  • If you allocate objects in one module and deallocate them in the other, your DLL and the client code must link to the same CRT 如果在一个模块中分配对象并在另一个模块中解除分配,则DLL和客户端代码必须链接到同一个CRT
  • It is very important that you keep the interface seperate from the implementation in your DLLs header files. 将接口与DLL头文件中的实现分开是非常重要的。 This means you often can't do thing like use std::string as function parameters, or even as private member variables. 这意味着您经常无法使用std :: string作为函数参数,甚至作为私有成员变量。

If I think of more or find more links, I'll add them. 如果我想到更多或找到更多链接,我会添加它们。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM