如何使用C ++源代码创建DLL,以及如何在其他源代码中使用它们? [英] How are DLLs created out of C++ source, and how are they used in other sources?

查看:155
本文介绍了如何使用C ++源代码创建DLL,以及如何在其他源代码中使用它们?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用C ++源代码创建DLL,以及如何在其他来源中使用它们?

How are DLLs created out of C++ source code, and how are they used in other sources?

推荐答案

一个'动态链接库',其工作原理很像其他库,但没有链接到可执行应用程序。在运行时你可以调用特定的函数来加载你的DLL和执行它的导出方法。

The DLL is a 'Dynamic Link Library' which works a lot like other libraries but is not linked with your executable application. At run time you can call specific functions for loading your DLL and executing its exported methods.

你可以尝试创建一个DLL - 使用visual studio创建一个项目,并指定DLL。这将为您的项目创建一些基本结构,例如项目的编译DLL设置,以及一些暴露方法,对象或变量的基本代码。

You can try creating a DLL yourself- create a project using visual studio and specify a DLL. This will create some of the base constructs for your project such as settings for your project to compile the DLL and also some base code for exposing methods, objects, or variables.

有很多步骤可以帮助你:

There are many walk through's to help you at this point: check here.

因此,总结:


  • DLL是一个您可以在runtim e加载的库。这是一个非常灵活的插件模型。示例:可以在运行时以编程方式选择和加载不同的DLL。每个DLL都可以是一个插件来提供不同的功能。

  • A DLL is a library which you can be loaded at runtime. This is a very flexible 'plug-in' model. Example: You can programmatically select and load different DLL at runtime. Each DLL can be a 'plug-in' to provide different functionality.

一个DLL有一个入口点。就像你的命令行可执行文件的Main函数是入口点一样,DLL有一个入口点函数,当DLL上出现不同的事件时,例如加载,卸载等。

A DLL Has an entry point. Just like your Main function of your command line executable is the entry point, the DLL has an entry point function which is called when different events occur on the DLL such as loading, unloading, and more.

要使用DLL,您必须使用DLL的导出对象或方法。

To use a DLL you must use the exported objects or methods of the DLL.

当从其他应用程序调用这些导出的函数时,非常重要的是您匹配兼容类型!此外,请确保调用约定是兼容的

When Calling these exported functions from another application it is very important that you match compatible types! Also, make sure the calling conventions are compatible

这篇关于如何使用C ++源代码创建DLL,以及如何在其他源代码中使用它们?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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