闭源库包括 boost 发行版

发布于 2024-10-06 02:19:09 字数 798 浏览 0 评论 0原文

我正在使用一个闭源库(由 Activ Financial 提供),该库在其 API 中包含一个 boost 发行版,包括一些 boost 头文件和 boost 库文件。

我还在现有代码库中使用 Boost,并且需要从现有代码中使用 Activ。

有些点

  • 我可以封装我对 Activ 的使用,以便整个 Activ 部分相当于我编写的一个类,它不会公开任何 Activ 的标头
  • 这个单个头文件不使用任何 boost 任何东西
  • 这样我就可以确保 Activ 部分我的代码使用 Activ 的 Boost HPP 文件,而我的代码使用我的 Boost 的 HPP 文件

我担心的是链接。如何确保我的 Activ 相关代码链接到 Activ 的 Boost,而我的其他代码链接到我的 Boost?

我现在使用 g++,也将在 VS2008 中执行此操作。我之前在 VS2008 中可以正常工作,但我不知道一切是如何联系起来的。我想尝试确保它正确完成。

有没有办法在不进一步将 Activ 部分封装在动态库中的情况下做到这一点?

编辑:

首先,我的最终产品始终是一个可执行文件。对于两个人,我通过静态链接来提升自己。 Activ 库包括静态和动态版本的 Boost 对象库,我计划静态链接它。

我从不在使用不同 boost 版本的代码之间传递 Boost 对象。

问题是,如何将一个 cpp 或 .o 文件链接到 一个 库文件中的对象,然后确保其他 .o 文件链接到另一个库文件中的相同对象?这可能吗?

I'm using a closed source library (by Activ financial) that includes with their API a boost distribution, both some boost header files and boost library files.

I also use Boost in my existing codebase, and I need to use Activ from my existing code.

Some points

  • I can encapsulate my use of Activ so that the entire Activ part amounts to a single class I wrote that does not expose any of Activ's headers
  • This single header file does not use any boost anything
  • In this way I can ensure that the Activ parts of my code use Activ's Boost HPP files, and my code uses my Boost's HPP files

My worry comes in linking. How can I ensure that my Activ dependent code links to Activ's Boost, and my other code links to my Boost?

I'm using g++ now, will also be doing this in VS2008. I got it working in VS2008 before, but I have no idea how everything linked. I want to try to make sure it's done correctly.

Is there a way to do it without further encapsulating the Activ part in a dynamic library?

Edit:

For one, my final product is always an executable file. For two, I statically link to boost myself. The Activ library includes both static and dynamic versions of Boost object libraries, and I plan to statically link it.

I never pass Boost objects between code that uses different boost versions.

The question is, how do I link one cpp or .o file to objects in one library file, and then make sure other .o files link to the identical objects in another library file? Is this possible?

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

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

发布评论

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

评论(1

骑趴 2024-10-13 02:19:09

该库是否动态或静态链接到 Boost?如果静态链接,库是否公开 DLL 中的符号(declspec 导出)?

如果库是静态链接的并且符号没有公开,并且您没有来回传递任何 Boost 数据结构(smart_ptr、线程等),那么您可能可以安全地使用您自己的版本DLL 中的 Boost 库。

Does the library dynamically or statically link to Boost? If statically linked, does the library expose the symbols in the DLL (declspec export)?

If the library is statically linked and the symbols are not exposed, and you do not pass any Boost data structures (smart_ptr, threads, etc) back and forth, you are likely safe to use your own version of the Boost library in your DLL.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文