boost::bind 似乎使用不同的编译器生成不同的符号

boost::bind seems to produce different symbols with different compilers?

本文关键字:编译器 符号 bind boost      更新时间:2023-10-16

我有一个使用模板和回调的共享对象库。我需要将其移植到另一个使用旧版 g++ (4.1.2) 的系统。

这是我正在做的伪代码:

shrdPtr.reset( new DataRecvr<T>(aString,boost::bind(&MyClass<T>::myCallBack, this,_1)));

适用于较新的编译器,但是当我在旧系统上构建它时,我在运行时找不到一个符号。

我使用 nm mySo.so | c++flt 将不工作的 so 与 ldd -u -r mySo.so

进行比较

在较新的编译器(g++ 4.4.7)上,它产生:
DataRecvr<TemplateName>::DataRecvr(std::basic_string<char,std::char_traits<char>,std::allocator<cahr> >const&, boost::function1,void,shrdPtr<TemplateName>&> const&

而在较旧的编译器上,它产生: DataRecvr<TemplateName>::DataRecvr(std::basic_string<char,std::char_traits<char>,std::allocator<char> >const&, boost::function1,void,shrdPtr<TemplateName>& std::allocator<boost::function_base> >const&)

如您所见,较旧的编译器在符号中产生了额外的内容,这些内容在运行时无法解决。

我在这里错过了什么?

似乎我包含了旧版本的提升。 给我带来问题的系统有多个版本的提升。 当我将包含路径设置为 boost_144 时,我的问题消失了。也许旧版本的 boost 会用绑定做一些奇怪的事情,这些事情与我正在使用的构造函数不兼容。