Boost logo

Boost Users :

Subject: [Boost-users] asio - failed to compile "chat_client.cpp" example on Cygwin
From: Steve Ong (stevenong_2006_at_[hidden])
Date: 2009-09-30 19:35:31


Hi,

I downloaded the "chat_client.cpp" from the boost website (http://www.boost.org/doc/libs/1_37_0/doc/html/boost_asio/examples.html) and try to compile it on Cygwin (see my compile statement below..), but it failed. It's worked on Linux (without the -D__USE_W32_SOCKETS -D_WIN32_WINNT=0x0501) , however.

Thanks in advance for your help.

Compile statement:

g++ -o chat_client chat_client.cpp -D__USE_W32_SOCKETS -D_WIN32_WINNT=0x0501 -Wall -I/opt/boost/include -L/opt/boost/lib -lboost_thread -lboost_system -lboost_t
hread

Output message:

/usr/lib/gcc/i686-pc-cygwin/3.4.4/../../../../i686-pc-cygwin/bin/ld: warning: au
to-importing has been activated without --enable-auto-import specified on the co
mmand line.
This should work unless it involves constant data structures referencing symbols
 from auto-imported DLLs./cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:ch
at_client.cpp:(.text$_ZN5boost4asio6detail12winsock_initILi2ELi0EE7do_initC1Ev[b
oost::asio::detail::winsock_init<2, 0>::do_init::do_init()]+0x1f): undefined ref
erence to `_WSAStartup_at_8'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops5closeEjRNS_6system10error_codeE[boost::asio::detai
l::socket_ops::close(unsigned int, boost::system::error_code&)]+0x18): undefined
 reference to `_closesocket_at_4'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops13error_wrapperIiEET_S4_RNS_6system10error_codeE[in
t boost::asio::detail::socket_ops::error_wrapper<int>(int, boost::system::error_
code&)]+0x13): undefined reference to `_WSAGetLastError_at_0'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops11clear_errorERNS_6system10error_codeE[boost::asio:
:detail::socket_ops::clear_error(boost::system::error_code&)]+0xf): undefined re
ference to `_WSASetLastError_at_4'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops6socketEiiiRNS_6system10error_codeE[boost::asio::de
tail::socket_ops::socket(int, int, int, boost::system::error_code&)]+0x3e): unde
fined reference to `_WSASocketA_at_24'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops6socketEiiiRNS_6system10error_codeE[boost::asio::de
tail::socket_ops::socket(int, int, int, boost::system::error_code&)]+0x9a): unde
fined reference to `_setsockopt_at_20'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops13error_wrapperIjEET_S4_RNS_6system10error_codeE[un
signed int boost::asio::detail::socket_ops::error_wrapper<unsigned int>(unsigned
 int, boost::system::error_code&)]+0x13): undefined reference to `_WSAGetLastErr
or_at_0'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops12call_connectIiEEiMNS2_6msghdrET_jPK8sockaddrj[int
 boost::asio::detail::socket_ops::call_connect<int>(int boost::asio::detail::soc
ket_ops::msghdr::*, unsigned int, sockaddr const*, unsigned int)]+0x1b): undefin
ed reference to `_connect_at_12'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops5ioctlEjlPmRNS_6system10error_codeE[boost::asio::de
tail::socket_ops::ioctl(unsigned int, long, unsigned long*, boost::system::error
_code&)]+0x26): undefined reference to `_ioctlsocket_at_12'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops11getaddrinfoEPKcS4_PK8addrinfoPPS5_RNS_6system10er
ror_codeE[boost::asio::detail::socket_ops::getaddrinfo(char const*, char const*,
 addrinfo const*, addrinfo**, boost::system::error_code&)]+0x2e): undefined refe
rence to `_getaddrinfo_at_16'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops24translate_addrinfo_errorEi[boost::asio::detail::s
ocket_ops::translate_addrinfo_error(int)]+0x228): undefined reference to `_WSAGe
tLastError_at_0'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops4sendEjPK7_WSABUFjiRNS_6system10error_codeE[boost::
asio::detail::socket_ops::send(unsigned int, _WSABUF const*, unsigned int, int,
boost::system::error_code&)]+0x57): undefined reference to `_WSASend_at_28'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops12freeaddrinfoEP8addrinfo[boost::asio::detail::sock
et_ops::freeaddrinfo(addrinfo*)]+0xd): undefined reference to `_freeaddrinfo_at_4'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops15call_setsockoptIiEEiMNS2_6msghdrET_jiiPKvj[int bo
ost::asio::detail::socket_ops::call_setsockopt<int>(int boost::asio::detail::soc
ket_ops::msghdr::*, unsigned int, int, int, void const*, unsigned int)]+0x29): u
ndefined reference to `_setsockopt_at_20'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail23win_iocp_socket_serviceINS0_2ip3tcpEE13async_receiveINS1_17co
nsuming_buffersINS0_14mutable_bufferENS0_17mutable_buffers_1EEENS1_12read_handle
rINS0_19basic_stream_socketIS4_NS0_21stream_socket_serviceIS4_EEEES9_NS1_14trans
fer_all_tENS_3_bi6bind_tIvNS_4_mfi3mf1Iv11chat_clientRKNS_6system10error_codeEEE
NSH_5list2INSH_5valueIPSL_EEPFNS_3argILi1EEEvEEEEEEEEEvRNS5_19implementation_typ
eERKT_iT0_[void boost::asio::detail::win_iocp_socket_service<boost::asio::ip::tc
p>::async_receive<boost::asio::detail::consuming_buffers<boost::asio::mutable_bu
ffer, boost::asio::mutable_buffers_1>, boost::asio::detail::read_handler<boost::
asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_servi
ce<boost::asio::ip::tcp> >, boost::asio::mutable_buffers_1, boost::asio::detail:
:transfer_all_t, boost::_bi::bind_t<void, boost::_mfi::mf1<void, chat_client, bo
ost::system::error_code const&>, boost::_bi::list2<boost::_bi::value<chat_client
*>, boost::arg<1> (*)()> > > >(boost::asio::detail::win_iocp_socket_service<boos
t::asio::ip::tcp>::implementation_type&, boost::asio::detail::consuming_buffers<
boost::asio::mutable_buffer, boost::asio::mutable_buffers_1> const&, int, boost:
:asio::detail::read_handler<boost::asio::basic_stream_socket<boost::asio::ip::tc
p, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::muta
ble_buffers_1, boost::asio::detail::transfer_all_t, boost::_bi::bind_t<void, boo
st::_mfi::mf1<void, chat_client, boost::system::error_code const&>, boost::_bi::
list2<boost::_bi::value<chat_client*>, boost::arg<1> (*)()> > >)]+0x41a): undefi
ned reference to `_WSARecv_at_28'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail23win_iocp_socket_serviceINS0_2ip3tcpEE13async_receiveINS1_17co
nsuming_buffersINS0_14mutable_bufferENS0_17mutable_buffers_1EEENS1_12read_handle
rINS0_19basic_stream_socketIS4_NS0_21stream_socket_serviceIS4_EEEES9_NS1_14trans
fer_all_tENS_3_bi6bind_tIvNS_4_mfi3mf1Iv11chat_clientRKNS_6system10error_codeEEE
NSH_5list2INSH_5valueIPSL_EEPFNS_3argILi1EEEvEEEEEEEEEvRNS5_19implementation_typ
eERKT_iT0_[void boost::asio::detail::win_iocp_socket_service<boost::asio::ip::tc
p>::async_receive<boost::asio::detail::consuming_buffers<boost::asio::mutable_bu
ffer, boost::asio::mutable_buffers_1>, boost::asio::detail::read_handler<boost::
asio::basic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_servi
ce<boost::asio::ip::tcp> >, boost::asio::mutable_buffers_1, boost::asio::detail:
:transfer_all_t, boost::_bi::bind_t<void, boost::_mfi::mf1<void, chat_client, bo
ost::system::error_code const&>, boost::_bi::list2<boost::_bi::value<chat_client
*>, boost::arg<1> (*)()> > > >(boost::asio::detail::win_iocp_socket_service<boos
t::asio::ip::tcp>::implementation_type&, boost::asio::detail::consuming_buffers<
boost::asio::mutable_buffer, boost::asio::mutable_buffers_1> const&, int, boost:
:asio::detail::read_handler<boost::asio::basic_stream_socket<boost::asio::ip::tc
p, boost::asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::muta
ble_buffers_1, boost::asio::detail::transfer_all_t, boost::_bi::bind_t<void, boo
st::_mfi::mf1<void, chat_client, boost::system::error_code const&>, boost::_bi::
list2<boost::_bi::value<chat_client*>, boost::arg<1> (*)()> > >)]+0x428): undefi
ned reference to `_WSAGetLastError_at_0'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail23win_iocp_socket_serviceINS0_2ip3tcpEE10async_sendINS1_17consu
ming_buffersINS0_12const_bufferENS0_17mutable_buffers_1EEENS1_13write_handlerINS
0_19basic_stream_socketIS4_NS0_21stream_socket_serviceIS4_EEEES9_NS1_14transfer_
all_tENS_3_bi6bind_tIvNS_4_mfi3mf1Iv11chat_clientRKNS_6system10error_codeEEENSH_
5list2INSH_5valueIPSL_EEPFNS_3argILi1EEEvEEEEEEEEEvRNS5_19implementation_typeERK
T_iT0_[void boost::asio::detail::win_iocp_socket_service<boost::asio::ip::tcp>::
async_send<boost::asio::detail::consuming_buffers<boost::asio::const_buffer, boo
st::asio::mutable_buffers_1>, boost::asio::detail::write_handler<boost::asio::ba
sic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost
::asio::ip::tcp> >, boost::asio::mutable_buffers_1, boost::asio::detail::transfe
r_all_t, boost::_bi::bind_t<void, boost::_mfi::mf1<void, chat_client, boost::sys
tem::error_code const&>, boost::_bi::list2<boost::_bi::value<chat_client*>, boos
t::arg<1> (*)()> > > >(boost::asio::detail::win_iocp_socket_service<boost::asio:
:ip::tcp>::implementation_type&, boost::asio::detail::consuming_buffers<boost::a
sio::const_buffer, boost::asio::mutable_buffers_1> const&, int, boost::asio::det
ail::write_handler<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost:
:asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::mutable_buffe
rs_1, boost::asio::detail::transfer_all_t, boost::_bi::bind_t<void, boost::_mfi:
:mf1<void, chat_client, boost::system::error_code const&>, boost::_bi::list2<boo
st::_bi::value<chat_client*>, boost::arg<1> (*)()> > >)]+0x3f4): undefined refer
ence to `_WSASend_at_28'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail23win_iocp_socket_serviceINS0_2ip3tcpEE10async_sendINS1_17consu
ming_buffersINS0_12const_bufferENS0_17mutable_buffers_1EEENS1_13write_handlerINS
0_19basic_stream_socketIS4_NS0_21stream_socket_serviceIS4_EEEES9_NS1_14transfer_
all_tENS_3_bi6bind_tIvNS_4_mfi3mf1Iv11chat_clientRKNS_6system10error_codeEEENSH_
5list2INSH_5valueIPSL_EEPFNS_3argILi1EEEvEEEEEEEEEvRNS5_19implementation_typeERK
T_iT0_[void boost::asio::detail::win_iocp_socket_service<boost::asio::ip::tcp>::
async_send<boost::asio::detail::consuming_buffers<boost::asio::const_buffer, boo
st::asio::mutable_buffers_1>, boost::asio::detail::write_handler<boost::asio::ba
sic_stream_socket<boost::asio::ip::tcp, boost::asio::stream_socket_service<boost
::asio::ip::tcp> >, boost::asio::mutable_buffers_1, boost::asio::detail::transfe
r_all_t, boost::_bi::bind_t<void, boost::_mfi::mf1<void, chat_client, boost::sys
tem::error_code const&>, boost::_bi::list2<boost::_bi::value<chat_client*>, boos
t::arg<1> (*)()> > > >(boost::asio::detail::win_iocp_socket_service<boost::asio:
:ip::tcp>::implementation_type&, boost::asio::detail::consuming_buffers<boost::a
sio::const_buffer, boost::asio::mutable_buffers_1> const&, int, boost::asio::det
ail::write_handler<boost::asio::basic_stream_socket<boost::asio::ip::tcp, boost:
:asio::stream_socket_service<boost::asio::ip::tcp> >, boost::asio::mutable_buffe
rs_1, boost::asio::detail::transfer_all_t, boost::_bi::bind_t<void, boost::_mfi:
:mf1<void, chat_client, boost::system::error_code const&>, boost::_bi::list2<boo
st::_bi::value<chat_client*>, boost::arg<1> (*)()> > >)]+0x402): undefined refer
ence to `_WSAGetLastError_at_0'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail12winsock_initILi2ELi0EE7do_initD1Ev[boost::asio::detail::winso
ck_init<2, 0>::do_init::~do_init()]+0x7): undefined reference to `_WSACleanup_at_0'

/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail25socket_select_interrupterC1Ev[boost::asio::detail::socket_sel
ect_interrupter::socket_select_interrupter()]+0x17f): undefined reference to `_i
net_addr_at_4'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops11call_acceptIiEEjMNS2_6msghdrET_jP8sockaddrPj[unsi
gned int boost::asio::detail::socket_ops::call_accept<int>(int boost::asio::deta
il::socket_ops::msghdr::*, unsigned int, sockaddr*, unsigned int*)]+0x4d): undef
ined reference to `_accept_at_12'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops6listenEjiRNS_6system10error_codeE[boost::asio::det
ail::socket_ops::listen(unsigned int, int, boost::system::error_code&)]+0x1f): u
ndefined reference to `_listen_at_8'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops16call_getsocknameIiEEiMNS2_6msghdrET_jP8sockaddrPj
[int boost::asio::detail::socket_ops::call_getsockname<int>(int boost::asio::det
ail::socket_ops::msghdr::*, unsigned int, sockaddr*, unsigned int*)]+0x23): unde
fined reference to `_getsockname_at_12'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops9call_bindIiEEiMNS2_6msghdrET_jPK8sockaddrj[int boo
st::asio::detail::socket_ops::call_bind<int>(int boost::asio::detail::socket_ops
::msghdr::*, unsigned int, sockaddr const*, unsigned int)]+0x1b): undefined refe
rence to `_bind_at_12'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops4recvEjP7_WSABUFjiRNS_6system10error_codeE[boost::a
sio::detail::socket_ops::recv(unsigned int, _WSABUF*, unsigned int, int, boost::
system::error_code&)]+0x57): undefined reference to `_WSARecv_at_28'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZNK
5boost4asio6detail18win_fd_set_adapter6is_setEj[boost::asio::detail::win_fd_set_
adapter::is_set(unsigned int) const]+0x14): undefined reference to `___WSAFDIsSe
t_at_8'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops6selectEiP6fd_setS4_S4_P7timevalRNS_6system10error_
codeE[boost::asio::detail::socket_ops::select(int, fd_set*, fd_set*, fd_set*, ti
meval*, boost::system::error_code&)]+0xe4): undefined reference to `_select_at_20'
/cygdrive/c/DOCUME~1/steven/LOCALS~1/Temp/ccKpZSDF.o:chat_client.cpp:(.text$_ZN5
boost4asio6detail10socket_ops15call_getsockoptIiEEiMNS2_6msghdrET_jiiPvPj[int bo
ost::asio::detail::socket_ops::call_getsockopt<int>(int boost::asio::detail::soc
ket_ops::msghdr::*, unsigned int, int, int, void*, unsigned int*)]+0x31): undefi
ned reference to `_getsockopt_at_20'
Info: resolving vtable for boost::detail::thread_data_baseby linking to __imp___
ZTVN5boost6detail16thread_data_baseE (auto-import)
collect2: ld returned 1 exit status
make: *** [chat_client] Error 1



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net