当我尝试在OS X上构建libocelot.dylib时,我遇到了针对boost的链接器错误。看起来这是在构建脚本的最后一步,当它运行命令时:
g++ -o .release_build/libocelot.dylib -lstdc++ -dynamiclib [...many *.os files referenced here ...] -L/usr/lib -L.release_build -L. -lboost_system-mt -lboost_filesystem-mt -lboost_thread-mt -lGLEW -ldl
这会产生几个未定义的符号错误,如下所示:
Undefined symbols for architecture x86_64:
"std::__detail::_List_node_base::_M_hook(std::__detail::_List_node_base*)", referenced from:
"std::__detail::_List_node_base::swap(std::__detail::_List_node_base&, std::__detail::_List_node_base&)", referenced from:
"std::__detail::_List_node_base::_M_unhook()", referenced from:
"std::__detail::_List_node_base::_M_transfer(std::__detail::_List_node_base*, std::__detail::_List_node_base*)", referenced from:
"std::__detail::__prime_list", referenced from:
"std::_Hash_bytes(void const*, unsigned long, unsigned long)", referenced from:
"std::ctype<char>::_M_widen_init() const", referenced from:
"_glGetError", referenced from:
其中大部分但并非全部似乎来自boost库。当我使用nm
检查来增强dylib文件时,我发现这些符号标有U
未定义:
lib$ nm *.dylib | grep _M_hook
U __ZNSt8__detail15_List_node_base7_M_hookEPS0_
U __ZNSt8__detail15_List_node_base7_M_hookEPS0_
U __ZNSt8__detail15_List_node_base7_M_hookEPS0_
U __ZNSt8__detail15_List_node_base7_M_hookEPS0_
U __ZNSt8__detail15_List_node_base7_M_hookEPS0_
U __ZNSt8__detail15_List_node_base7_M_hookEPS0_
lib$ nm *.dylib | grep _M_unhook
U __ZNSt8__detail15_List_node_base9_M_unhookEv
U __ZNSt8__detail15_List_node_base9_M_unhookEv
U __ZNSt8__detail15_List_node_base9_M_unhookEv
U __ZNSt8__detail15_List_node_base9_M_unhookEv
等等。因此,出于某种原因,ocelot正在寻找的符号并不是在boost中构建的。关于我可能做错了什么或者替代方法的任何想法?为了提升建筑效果,我按照下面的说明进行了操作。
http://www.boost.org/doc/libs/1_48_0/more/getting_started/unix-variants.html