混合使用C ++ ABI来构建旧的库 [英] Mixing C++ ABIs to build against legacy libraries

查看:158
本文介绍了混合使用C ++ ABI来构建旧的库的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这里的情况,我有一个C ++代码库使用最近的GCC(4.3.3),但我需要链接到一个旧的库,它是使用GCC 3.2.3构建的。没有更新版本的库可用,我不能去没有它,它是关闭源,所以它不能重建。

Here's the situation, I've got a C++ codebase which is using a recent GCC (4.3.3), but I need to link against an older library which was built using GCC 3.2.3. There is no newer version of the library available, I can't go without it, and it's closed source so it can't be rebuilt.

这似乎提出了一个问题,因为有GCC 4.3.3和3.2.3之间的ABI不兼容,所以我试图看看我的选项是用于解决这个。

This seems to pose a problem since there are ABI incompatibilities between GCC 4.3.3 and 3.2.3, so I'm trying to see what my options are for resolving this.

一些额外的细节:


  • 我可以使用-fabi-version = 1重建我的代码库中的所有内容以获得正确的ABI版本,


  • 代码库外的所有C ++库依赖都是开源的,所以我可以根据需要重建它们,除了这个库。 $ b
  • 许多C库依赖项无法重建或难以重建。

  • 旧库似乎依赖于某些libstdc ++版本5功能

  • I can rebuild everything in my codebase with -fabi-version=1 to get the correct ABI version, but I am dependent on some newer features from libstdc++ version 6.
  • All the C++ library dependencies outside the codebase are open source, so I can rebuild them as needed, except for this one library.
  • Many C library dependencies that cannot be rebuilt or would be difficult to rebuild.
  • The old library seems to be dependent on some libstdc++ version 5 features

我到目前为止尝试过:


  • 重建所有C ++代码依赖库与-fabi-version = 1并链接到libstdc ++版本6.这失败与C ++标准库符号的一些未定义的符号错误。

  • 与上面相同,但另外链接libstdc ++ 5的共享库,这解决了链接器问题,但似乎导致在旧版本库中的两个版本在运行时混合,并导致崩溃。

我读了这个网页: http://gcc.gnu.org/onlinedocs/ libstdc ++ / manual / abi.html ,这似乎表明可以在应用程序中混合C ++ ABI版本,以满足库之间不同的依赖性。

I read this page: http://gcc.gnu.org/onlinedocs/libstdc++/manual/abi.html which seems to indicate that it can be possible to mix C++ ABI versions in an application to satisfy varying dependencies between libraries. It doesn't seem to work very well here, though, unless I am missing something.

任何想法?

推荐答案

好,您的解决方法是:


  • C / C ++库,用3.2.3编译,所以它会工作。

  • 现在你可以在新编译器中使用C接口。

您可以在C库中编写一些C ++包装器代码,因此您将使用它作为C ++,但是这个代码将在新编译器中构建。

You can write some C++ "wrapper" code around the C library so you will use it as C++ but this code will be built in the new compiler.

这篇关于混合使用C ++ ABI来构建旧的库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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