Maybe this is a stupid problem , but I really don't konw how to find
the right way.
My compile environment is
WinXP,
Msys ,
MinGw ,
G++ 3.4.2,
Boost 1.33.1,
asio_0_3_7,
bjam 3.1.13.
I have already copy the header files of boost and asio into mingw/include
I write the helloWorld.cpp follow the tutorial.
#include <iostream>
#include
#include
int main()
{
boost::asio::io_service io;
boost::asio::deadline_timer t(io, boost::posix_time::seconds(5));
t.wait();
std::cout << "Hello, world!\n";
return 0;
}
I write Jamroot as follow:
exe hello : hello.cpp ;
then I compile it in Msys, but link wrong happened(wrong messages see
the end of this Email).
Would you please help me to solve this problem .
Thank you for(;;){} //forever
$ bjam
...found 11 targets...
...updating 5 targets...
MkDir1 bin
MkDir1 bin\gcc
MkDir1 bin\gcc\debug
gcc.compile.c++ bin\gcc\debug\hello.o
In file included from
e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/detail/win_local_free_on_block_exit.hpp:27,
from
e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/system_exception.hpp:33,
from
e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/detail/win_mutex.hpp:26,
from
e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/detail/mutex.hpp:27,
from
e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/detail/service_registry.hpp:25,
from
e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/io_service.hpp:32,
from
e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/basic_io_object.hpp:20,
from
e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/basic_socket.hpp:20,
from
e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/basic_datagram_socket.hpp:25,
from
e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio.hpp:18,
from hello.cpp:11:
e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/detail/socket_types.hpp:31:5:
warning: #warning Please define _WIN32_WINNT or _WIN32_WINDOWS
appropriately
e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/detail/socket_types.hpp:32:5:
warning: #warning Assuming _WIN32_WINNT=0x0500 (i.e. Windows 2000
target)
hello.cpp:24:2: warning: no newline at end of file
gcc.link bin\gcc\debug\hello.exe
bin\gcc\debug\hello.o: In function
`ZN5boost4asio6detail31reactive_deadline_timer_serviceINS0_11time_traitsINS_10posix_time5ptimeEEENS1_14select_reactorILb1EEEE16shutdown_serviceEv':e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail12winsock_initILi2ELi0EE7do_initC1Ev[boost::asio::detail::winsock_init<2,
0>::do_init::do_init()]+0x1f): undefined reference to `WSAStartup@8'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops6selectEiP6fd_setS4_S4_P7timeval[boost::asio::detail::socket_ops::select(int,
fd_set*, fd_set*, fd_set*, timeval*)]+0xc9): undefined reference to
`select@20'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops13error_wrapperIiEET_S4_[int
boost::asio::detail::socket_ops::error_wrapper<int>(int)]+0x8):
undefined reference to `WSAGetLastError@0'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops9set_errorEi[boost::asio::detail::socket_ops::set_error(int)]+0x17):
undefined reference to `WSASetLastError@4'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail12winsock_initILi2ELi0EE7do_initD1Ev[boost::asio::detail::winsock_init<2,
0>::do_init::~do_init()]+0x7): undefined reference to `WSACleanup@0'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops5closeEj[boost::asio::detail::socket_ops::close(unsigned
int)]+0x19): undefined reference to `closesocket@4'
bin\gcc\debug\hello.o: In function
`main':e:/job/word-online/source/cpp/hello.cpp:15: undefined reference
to `inet_addr@4'
:e:/job/word-online/source/cpp/hello.cpp:23: undefined reference to
`getsockname@12'
bin\gcc\debug\hello.o: In function
`ZN5boost4asio6detail31reactive_deadline_timer_serviceINS0_11time_traitsINS_10posix_time5ptimeEEENS1_14select_reactorILb1EEEE16shutdown_serviceEv':e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../..
o `closesocket@4'
bin\gcc\debug\hello.o: In function
`main':e:/job/word-online/source/cpp/hello.cpp:15: undefined reference
to `inet_addr@4'
:e:/job/word-online/source/cpp/hello.cpp:23: undefined reference to
`getsockname@12'
bin\gcc\debug\hello.o: In function
`ZN5boost4asio6detail31reactive_deadline_timer_serviceINS0_11time_traitsINS_10posix_time5ptimeEEENS1_14select_reactorILb1EEEE16shutdown_serviceEv':e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops5ioctlEjlPm[boost::asio::detail::socket_ops::ioctl(unsigned
int, long, unsigned long*)]+0x27): undefined reference to
`ioctlsocket@12'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops6acceptEjP8sockaddrPi[boost::asio::detail::socket_ops::accept(unsigned
int, sockaddr*, int*)]+0x27): undefined reference to `accept@12'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops13error_wrapperIjEET_S4_[unsigned
int boost::asio::detail::socket_ops::error_wrapper<unsigned
int>(unsigned int)]+0x8): undefined reference to `WSAGetLastError@0'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops7connectEjPK8sockaddri[boost::asio::detail::socket_ops::connect(unsigned
int, sockaddr const*, int)]+0x27): undefined reference to `connect@12'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops6listenEji[boost::asio::detail::socket_ops::listen(unsigned
int, int)]+0x20): undefined reference to `listen@8'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops4bindEjPK8sockaddri[boost::asio::detail::socket_ops::bind(unsigned
int, sockaddr const*, int)]+0x27): undefined reference to `bind@12'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops10setsockoptEjiiPKvj[boost::asio::detail::socket_ops::setsockopt(unsigned
int, int, int, void const*, unsigned int)]+0x35): undefined reference
to `setsockopt@20'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops9get_errorEv[boost::asio::detail::socket_ops::get_error()]+0x7):
undefined reference to `WSAGetLastError@0'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops6socketEiii[boost::asio::detail::socket_ops::socket(int,
int, int)]+0x3f): undefined reference to `WSASocketA@24'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops4recvEjP7_WSABUFji[boost::asio::detail::socket_ops::recv(unsigned
int, _WSABUF*, unsigned int, int)]+0x58): undefined reference to
`WSARecv@28'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZNK5boost4asio6detail14fd_set_adapter6is_setEj[boost::asio::detail::fd_set_adapter::is_set(unsigned
int) const]+0x14): undefined reference to `__WSAFDIsSet@8'
:e:/program/mingw/mingw/bin/../lib/gcc/i686-pc-mingw32/3.4.2/../../../../include/boost/asio/deadline_timer_service.hpp:(.text$_ZN5boost4asio6detail10socket_ops4sendEjPK7_WSABUFji[boost::asio::detail::socket_ops::send(unsigned
int, _WSABUF const*, unsigned int, int)]+0x58): undefined reference to
`WSASend@28'
collect2: ld returned 1 exit status
"g++" -o "bin\gcc\debug\hello.exe" -Wl,--start-group
"bin\gcc\debug\hello.o" -Wl,--end-group -g
...failed gcc.link bin\gcc\debug\hello.exe...
...failed updating 1 target...
...updated 4 targets...
--
I'm Earth-Man.
我是地球人.
--zsp(张沈鹏)