是否可以将用 c++11 编译的库 link 转换为需要用 c++03 编译的代码

is it possible to link a library compiled with c++11 to a code which needs to be compiled with c++03

我有 ogre 渲染代码,它用 c++03 编译但不能用 c++11 编译。

我有使用 c++11 而不是 c++03 编译的子弹物理代码。

现在我想连接它们。是否可以使用 c++11 编译项目符号代码并从要使用 c++03 编译的 ogre 代码调用生成的库。

我的 gcc 版本 4.8.4

OGRE 是静态构建的。 Bullet 也是静态构建的。

是的,只要您使用相同的 libstdc++ ABI 就可以,并且随着 g++ 5.1 引入了新的 C++ 11 ABI(参见 using dual abi),它应该适合您。

编辑:请参阅 this answer 以获得更完整的答案,特别是关于 ABI 与 g++ 4.7.0 和 g++ 4.7.1 的不兼容性