我在跟踪these instructions编译名为SDPB的程序时遇到问题。总而言之,我在Mac OS X Yosemite上安装了一个需要Boost,GMP和OpenMP的程序。所有单独的代码片段都会编译,但是当它的链接时间到来时,我得到Undefined symbols for architecture x86_64
。
我的问题与this question基本相同。但是,我无法得到那里的答案为我工作。我仍然得到同样的错误。
经过更多的搜索,我看到有类似问题的人得到的答案指出了clang和gcc之间的冲突。更具体地说,混合库libstdc ++和libc ++存在问题。
因此,我确保使用gcc重新编译Boost和GMP,以便使用libstdc ++构建所有内容。这没有用。然后我下载了一个与OpenMP兼容的clang实现,并尝试使用libc ++构建所有内容。这也行不通。然后,我使用带有-stdlib=libstdc++
标志的clang尝试了各种排列,依此类推。似乎没什么用。错误的细节似乎随着各种变化而有所改变。我将在下面发布几个片段。当然,我总是使用更新的makefile来编译SDPB,我总是使用--enable-cxx
标志配置GMP作为上面链接的答案。
这里是我在用gcc编译GMP和Boost后用gcc编译SDPB时收到的错误的片段。
Undefined symbols for architecture x86_64:
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::find(char const*, unsigned long, unsigned long) const", referenced from:
boost::date_time::time_facet<boost::posix_time::ptime, char, std::ostreambuf_iterator<char, std::char_traits<char> > >::put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, boost::posix_time::time_duration const&) const in SDPSolverIO.o
boost::date_time::time_facet<boost::posix_time::ptime, char, std::ostreambuf_iterator<char, std::char_traits<char> > >::put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, boost::posix_time::ptime const&) const in main.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const", referenced from:
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> > >::_M_get_insert_unique_pos(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in SDPSolverIO.o
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> > >::_M_get_insert_hint_unique_pos(std::_Rb_tree_const_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in SDPSolverIO.o
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> > >::_M_insert_unique_(std::_Rb_tree_const_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> const&) in SDPSolverIO.o
std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::timer::cpu_timer, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> > >::operator[](std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in SDPSolverIO.o
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::program_options::variable_value>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::program_options::variable_value> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::program_options::variable_value> > >::find(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const in main.o
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::_M_get_insert_unique_pos(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in main.o
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::_M_get_insert_hint_unique_pos(std::_Rb_tree_const_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in main.o
...
在这里,我使用带有-stdlib=libstdc++
标志的clang编译了GMP和Boost,并使用gcc编译了SDPB。
Undefined symbols for architecture x86_64:
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::find(char const*, unsigned long, unsigned long) const", referenced from:
boost::date_time::time_facet<boost::posix_time::ptime, char, std::ostreambuf_iterator<char, std::char_traits<char> > >::put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, boost::posix_time::time_duration const&) const in SDPSolverIO.o
boost::date_time::time_facet<boost::posix_time::ptime, char, std::ostreambuf_iterator<char, std::char_traits<char> > >::put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, boost::posix_time::ptime const&) const in main.o
"std::basic_string<char, std::char_traits<char>, std::allocator<char> >::compare(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const", referenced from:
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> > >::_M_get_insert_unique_pos(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in SDPSolverIO.o
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> > >::_M_get_insert_hint_unique_pos(std::_Rb_tree_const_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in SDPSolverIO.o
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> > >::_M_insert_unique_(std::_Rb_tree_const_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> const&) in SDPSolverIO.o
std::map<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, boost::timer::cpu_timer, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::timer::cpu_timer> > >::operator[](std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in SDPSolverIO.o
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::program_options::variable_value>, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::program_options::variable_value> >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, boost::program_options::variable_value> > >::find(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) const in main.o
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::_M_get_insert_unique_pos(std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in main.o
std::_Rb_tree<std::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::_Select1st<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::less<std::basic_string<char, std::char_traits<char>, std::allocator<char> > >, std::allocator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > > >::_M_get_insert_hint_unique_pos(std::_Rb_tree_const_iterator<std::pair<std::basic_string<char, std::char_traits<char>, std::allocator<char> > const, std::basic_string<char, std::char_traits<char>, std::allocator<char> > > >, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&) in main.o
...
在这里,我使用带有-stdlib=libstdc++
标志的clang编译了Boost,GMP和SDPB。
Undefined symbols for architecture x86_64:
"std::string::find(char const*, unsigned long, unsigned long) const", referenced from:
boost::date_time::time_facet<boost::posix_time::ptime, char, std::ostreambuf_iterator<char, std::char_traits<char> > >::put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, boost::posix_time::time_duration const&) const in SDPSolverIO.o
boost::date_time::time_facet<boost::posix_time::ptime, char, std::ostreambuf_iterator<char, std::char_traits<char> > >::put(std::ostreambuf_iterator<char, std::char_traits<char> >, std::ios_base&, char, boost::posix_time::ptime const&) const in main.o
"std::logic_error::what() const", referenced from:
vtable for boost::gregorian::bad_day_of_year in main.o
vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::gregorian::bad_day_of_year> > in main.o
vtable for boost::exception_detail::error_info_injector<boost::gregorian::bad_day_of_year> in main.o
vtable for std::out_of_range in main.o
vtable for boost::gregorian::bad_day_of_month in main.o
vtable for boost::exception_detail::clone_impl<boost::exception_detail::error_info_injector<boost::gregorian::bad_day_of_month> > in main.o
vtable for boost::exception_detail::error_info_injector<boost::gregorian::bad_day_of_month> in main.o
...
在这里,我使用clang但仅使用带有-stdlib=libstdc++
标志的SDPB编译了所有内容。
Undefined symbols for architecture x86_64:
"bootstrapSDP(std::vector<__gmp_expr<__mpf_struct [1], __mpf_struct [1]>, std::allocator<__gmp_expr<__mpf_struct [1], __mpf_struct [1]> > > const&, std::vector<PolynomialVectorMatrix, std::allocator<PolynomialVectorMatrix> > const&)", referenced from:
parseBootstrapSDP(tinyxml2::XMLElement*) in parse.o
"RpotrfStabilized(char const*, int, __gmp_expr<__mpf_struct [1], __mpf_struct [1]>*, int, int*, std::__1::vector<int, std::__1::allocator<int> >&, std::__1::vector<__gmp_expr<__mpf_struct [1], __mpf_struct [1]>, std::__1::allocator<__gmp_expr<__mpf_struct [1], __mpf_struct [1]> > >&, double)", referenced from:
choleskyDecompositionStabilized(Matrix&, Matrix&, std::__1::vector<int, std::__1::allocator<int> >&, std::__1::vector<__gmp_expr<__mpf_struct [1], __mpf_struct [1]>, std::__1::allocator<__gmp_expr<__mpf_struct [1], __mpf_struct [1]> > >&, double) in Matrix.o
"boost::program_options::to_internal(std::string const&)", referenced from:
std::vector<std::string, std::allocator<std::string> > boost::program_options::to_internal<std::string>(std::vector<std::string, std::allocator<std::string> > const&) in main.o
"boost::program_options::basic_parsed_options<char> boost::program_options::parse_config_file<char>(std::basic_istream<char, std::char_traits<char> >&, boost::program_options::options_description const&, bool)", referenced from:
_main in main.o
"boost::program_options::options_description::options_description(std::string const&, unsigned int, unsigned int)", referenced from:
_main in main.o
每当我尝试在没有-stdlib=libstdc++
的情况下编译SDPB时使用修改版的clang和OpenMP支持,我就会遇到很多
error: 'value_type' is a private member of '__gmp_expr<mpf_t, mpf_t>'
__val_expr<_BinaryOp<__bit_shift_left<typename _Expr::value_type>,
^
src/serialize.h:48:10: note: while substituting deduced template arguments into function template 'operator<<' [with _Expr = __gmp_expr<mpf_t, mpf_t>]
os << f;
如果有人能提供帮助,我们将不胜感激。