g++ linker unable to find winsock functions
Asked Answered
D

0

7

I am using MinGW-w64 to link a torrent downloader but it doesn't work. Does someone have an idea about what could be the problem?

g++.exe -o ./Debug/athorrentd @"athorrentd.txt" -lws2_32 -lwsock32 -lboost_program_options-mgw49-mt-1_58 -lboost_filesystem-mgw49-mt-1_58 -lboost_thread-mgw49-mt-1_58 -ljson -lboost_system-mgw49-mt-1_58 -lboost_locale-mgw49-mt-1_58 -ltorrent-rasterbar


D:/dev/mingw/64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/libtorrent-rasterbar.a(asio.o): In function `boost::asio::detail::winsock_init_base::startup(boost::asio::detail::winsock_init_base::data&, unsigned char, unsigned char)':
d:/dev/mingw/64/mingw64/x86_64-w64-mingw32/include/boost/asio/detail/impl/winsock_init.ipp:39: undefined reference to `__imp_WSAStartup'
D:/dev/mingw/64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/libtorrent-rasterbar.a(asio.o): In function `clear_last_error':
d:/dev/mingw/64/mingw64/x86_64-w64-mingw32/include/boost/asio/detail/impl/socket_ops.ipp:69: undefined reference to `__imp_WSASetLastError'
D:/dev/mingw/64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/libtorrent-rasterbar.a(asio.o): In function `call_accept<int>':
d:/dev/mingw/64/mingw64/x86_64-w64-mingw32/include/boost/asio/detail/impl/socket_ops.ipp:96: undefined reference to `__imp_accept'
D:/dev/mingw/64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/libtorrent-rasterbar.a(asio.o): In function `error_wrapper<long long unsigned int>':
d:/dev/mingw/64/mingw64/x86_64-w64-mingw32/include/boost/asio/detail/impl/socket_ops.ipp:82: undefined reference to `__imp_WSAGetLastError'
D:/dev/mingw/64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/libtorrent-rasterbar.a(asio.o): In function `call_accept<int>':
d:/dev/mingw/64/mingw64/x86_64-w64-mingw32/include/boost/asio/detail/impl/socket_ops.ipp:96: undefined reference to `__imp_accept'
D:/dev/mingw/64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/libtorrent-rasterbar.a(asio.o): In function `clear_last_error':
d:/dev/mingw/64/mingw64/x86_64-w64-mingw32/include/boost/asio/detail/impl/socket_ops.ipp:69: undefined reference to `__imp_WSASetLastError'
D:/dev/mingw/64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/libtorrent-rasterbar.a(asio.o): In function `call_bind<int>':
d:/dev/mingw/64/mingw64/x86_64-w64-mingw32/include/boost/asio/detail/impl/socket_ops.ipp:276: undefined reference to `__imp_bind'
D:/dev/mingw/64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/libtorrent-rasterbar.a(asio.o): In function `error_wrapper<int>':
d:/dev/mingw/64/mingw64/x86_64-w64-mingw32/include/boost/asio/detail/impl/socket_ops.ipp:82: undefined reference to `__imp_WSAGetLastError'
D:/dev/mingw/64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/libtorrent-rasterbar.a(asio.o): In function `clear_last_error':
d:/dev/mingw/64/mingw64/x86_64-w64-mingw32/include/boost/asio/detail/impl/socket_ops.ipp:69: undefined reference to `__imp_WSASetLastError'
D:/dev/mingw/64/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.9.2/../../../../x86_64-w64-mingw32/lib/../lib/libtorrent-rasterbar.a(asio.o): In function `boost::asio::detail::socket_ops::set_user_non_blocking(unsigned long long, unsigned char&, bool, boost::system::error_code&)':
d:/dev/mingw/64/mingw64/x86_64-w64-mingw32/include/boost/asio/detail/impl/socket_ops.ipp:373: undefined reference to `__imp_ioctlsocket'
...
Dneprodzerzhinsk answered 10/6, 2015 at 1:53 Comment(2)
try moving -lws2_32 -lwsock32 to the end.Giga
Linking order often matters due to dependency chains.Monomorphic

© 2022 - 2024 — McMap. All rights reserved.