我正在尝试编译这个程序:
http://lists.boost.org/boost-users/att-40895/telnet.cpp
在OS X 10.7.3的Mac上。
我正在使用这一行来编译:
g++ -O3 telnet.cpp -o telnet
我收到了这个错误:
Undefined symbols for architecture x86_64:
"boost::system::generic_category()", referenced from:
global constructors keyed to _ZN12_GLOBAL__N_12_1Ein cc4A3W1S.o
"boost::system::system_category()", referenced from:
global constructors keyed to _ZN12_GLOBAL__N_12_1Ein cc4A3W1S.o
boost::asio::detail::posix_thread::func<boost::asio::detail::resolver_service_base::work_io_service_runner>::run()in cc4A3W1S.o
boost::asio::detail::reactive_socket_connect_op_base::do_perform(boost::asio::detail::reactor_op*)in cc4A3W1S.o
boost::asio::detail::socket_ops::translate_netdb_error(int) in cc4A3W1S.o
boost::asio::ip::basic_resolver_iterator<boost::asio::ip::tcp>::create(addrinfo*, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)in cc4A3W1S.o
boost::asio::detail::socket_ops::translate_addrinfo_error(int) in cc4A3W1S.o
boost::asio::detail::kqueue_reactor::run(bool, boost::asio::detail::op_queue<boost::asio::detail::task_io_service_operation>&)in cc4A3W1S.o
...
"vtable for boost::detail::thread_data_base", referenced from:
boost::detail::thread_data_base::thread_data_base()in cc4A3W1S.o
NOTE: a missing vtable usually means the first non-inline virtual member function has no definition.
"boost::detail::thread_data_base::~thread_data_base()", referenced from:
boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >::~thread_data()in cc4A3W1S.o
boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >::~thread_data()in cc4A3W1S.o
"boost::thread::start_thread()", referenced from:
boost::thread::thread<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >(boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > >, boost::disable_if<boost::is_convertible<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > >&, boost::detail::thread_move_t<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > > >, boost::thread::dummy*>::type)in cc4A3W1S.o
"boost::thread::join()", referenced from:
_main in cc4A3W1S.o
"boost::thread::~thread()", referenced from:
_main in cc4A3W1S.o
"telnet_client::~telnet_client()", referenced from:
_main in cc4A3W1S.o
"typeinfo for boost::detail::thread_data_base", referenced from:
typeinfo for boost::detail::thread_data<boost::_bi::bind_t<unsigned long, boost::_mfi::mf0<unsigned long, boost::asio::io_service>, boost::_bi::list1<boost::_bi::value<boost::asio::io_service*> > > >in cc4A3W1S.o
ld: symbol(s) not found for architecture x86_64
collect2: ld returned 1 exit status
从我迄今为止的研究中我得出的是,我需要以某种方式链接到boost库。我不知道如何判断它是否正确安装。我下载了brew并使用了
brew install boost
安装它。
对不起,如果格式错误,这是我的第一篇文章。谢谢您的帮助。如果我需要提供任何其他信息,请告诉我。
答案 0 :(得分:2)
您忘记链接Boost库。尝试:
g++ -O3 -o telnet telnet.cpp -lboost_system -lboost_thread
答案 1 :(得分:0)
您可能需要-l boost_thread-mt而不是-lboost_thread我没有看过代码,但可能就是这种情况