在C或C实现插件系统++ [英] Implementing A Plugin System in C or C++

查看:157
本文介绍了在C或C实现插件系统++的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你对实现插件式的系统提示吗?

What are your tips on implementing a plugin style system?

推荐答案

在C(我认为C ++太虽然我没有做我自己),这是使用动态加载模块最典型的完成。该API:S对于如依赖于平台的

In C (and I think C++ too although I haven't done it myself), this is most typically done using dynamically loaded modules. The API:s for such are platform-dependent.

在POSIX(Linux)的,您可以使用 dlopen()的 系列函数。基本上你单独建立自己的插件,然后在运行时加载它,通过名称来查找它的符号,然后可以给他们打电话。

On POSIX (Linux), you use the dlopen() family of functions. Basically you build your plugin separately, then load it at run-time, look up its symbols by name, and can then call them.

对于Win32,有 调用LoadLibrary() 这确实非常类似的东西,你建立你的code到DLL。

For Win32, there is LoadLibrary() which does something very similar, you build your code into a DLL.

有关一个方便的包装,使所有的这些简单而透明,检查GLib的的的 GModule API。

For a handy wrapper that makes all of these easy and transparent, check out GLib's GModule API.

这篇关于在C或C实现插件系统++的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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