便携式 C++组件设计
我过去一直使用 COM 和 .NET 程序集来开发基于组件的系统。现在我要处理一个跨平台的 C++ 项目,并希望在组件中构建代码......
显然 COM 和 .NET 不是一个选项,因为 COM 在任何地方都不可用,但 Windows 和程序集会添加依赖项.NET 框架可能在目标系统上不可用。
我知道,由于 ABI 差异,如果不重新编译,我将无法在不同操作系统之间移动组件,但我想以在源代码级别兼容的方式编写代码。
是否有任何系统/框架可以在 C++ 中实现这样的架构?
I've been using COM and .NET assemblies in the past to develop component-based-systems. Now I'm going to work on a cross-plattform-C++-project and want to structure the code in components aswell…
Obviously COM and .NET are not an option, as COM is not available anywhere but Windows and Assemblies would add dependencies to the .NET framwork which may be not available at the target system.
I'm aware that due to ABI-differences I won't be able to move components between different operating systems without recompilation, but I would like to write the code in a manner, that it's compatible at source-code-level.
Is there any system/framework that enables such a architecture in C++?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
我过去曾使用过这样的系统 - 我们基本上重新发明了 COM。如果您对这种方法感兴趣,请查看这篇精彩的文章:http://msdn .microsoft.com/en-us/library/ms809983.aspx
I have worked with such a system in the past - we basically re-invented COM. If you are interested in that approach, check out this great article: http://msdn.microsoft.com/en-us/library/ms809983.aspx
Mozilla 套件使用名为 XPCOM 的框架。我自己从未使用过它,但暗示它应该像微软的 COM 但可移植。这是我所知道的唯一基于本机代码的进程内组件系统;如果您使用 Java,则有 OSGi。
如今,大多数 Unix 软件似乎都使用分布式组件模型,其中组件位于不同的进程中。当前流行的系统似乎是DBus; KDE3 使用了名为 DCOP 的替代方案;当然,如果您想走这条路,还有很好的旧 CORBA。
The Mozilla suite uses a framework called XPCOM. Never used it myself, but the implication it's supposed to be like Microsoft's COM but portable. That's the only in-process component system I know of that's native code based; if you're working in Java, there's OSGi.
These days most Unix software appears to use distributed component models, where components live in different processes. The current fashionable system appears to be DBus; KDE3 used an alternative called DCOP; and of course if you want to go this route there's good old CORBA.
如果您可以忍受 Qt 依赖项(只有核心库,没有 GUI 库),您可以查看 CTK 插件框架
它在 Apache 2.0 下获得许可,是一个动态 C++ 组件系统,其 API 与 OSGi 几乎相同。
If you can live with a Qt dependency (only core libraries, no GUI libs), you could have a look at the CTK Plugin Framework
It is licensed under Apache 2.0 and is a dynamic C++ component system with an API which is nearly identical to OSGi.
也许是这样的: http://blog.redshoelace.com/2007/09/什么是boostextension.html
Maybe this: http://blog.redshoelace.com/2007/09/what-is-boostextension.html