跨平台 C++动态库插件加载器

发布于 2024-09-27 20:38:26 字数 543 浏览 0 评论 0原文

我只是想知道使用共享库动态加载插件的跨平台实现的选项是什么。到目前为止,我发现的唯一一个是:

我只是想知道我是否还有其他选择?本质上,我希望能够将插件放入共享对象文件中,并在运行时加载它们,并且我希望以跨平台 C++ 的方式来实现。

编辑:我找到了多布斯博士帖子 从 2007 年开始;从那时起肯定有人想出了更多的东西。

I was just wondering what my options were for cross-platform implementations for the dynamic loading of plugins using shared libraries. So far the only one that I have found is:

And I was just wondering if I had other options? Essentially, I want to be able to put plugins in shared object files, and load them at runtime and I wanted to do it in a cross-platform C++ way.

Edit: I found this Dr Dobbs Post from 2007; surely somebody has come up with something more since then.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

聚集的泪 2024-10-04 20:38:26

您可以查看Boost Extension,尽管它还没有被 Boost 接受。

Boost.Extension 库已
开发是为了简化开发
插件和类似的扩展
使用共享库的软件。
类、函数和数据可以是
可从共享库中获取
并由应用程序加载。

You could look into Boost Extension, though it has not yet been accepted into Boost.

The Boost.Extension library has been
developed to ease the development of
plugins and similar extensions to
software using shared libraries.
Classes, functions and data can be
made available from shared libraries
and loaded by the application.

絕版丫頭 2024-10-04 20:38:26

Qt 有一个很好的插件系统。您应该查看 该页面的第二部分

Qt has a nice plugin system. You should take a look at the second part of that page.

蓝天白云 2024-10-04 20:38:26

如果您想要简单且轻量级的东西,请尝试: https://pocoproject.org/docs/package- Foundation.SharedLibrary.html

使用 SharedLibrary 类,需要三行代码来调用 C 共享库中的函数:

Poco::SharedLibrary lib("libfoo.so");
int (* foo)(int) = reinterpret_cast<int (*)(int)>(lib.getSymbol("foo"));    
printf("answer %d\n", foo(5));

If you want something simple and lightweight try: https://pocoproject.org/docs/package-Foundation.SharedLibrary.html

Using the SharedLibrary class it takes three lines to call a function in a C shared library:

Poco::SharedLibrary lib("libfoo.so");
int (* foo)(int) = reinterpret_cast<int (*)(int)>(lib.getSymbol("foo"));    
printf("answer %d\n", foo(5));
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文