Wednesday, August 25, 2010

Unresolved externals while linking application using cURL

When you are building your application, which uses libcurl, you can get some linker errors like the following:
3>libcurld.lib(select.obj) : error LNK2001: unresolved external symbol __imp__select@20
3>libcurld.lib(easy.obj) : error LNK2019: unresolved external symbol __imp__WSACleanup@0 referenced in function _win32_init
3>libcurld.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp__WSACleanup@0
3>libcurld.lib(easy.obj) : error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function _win32_init
3>libcurld.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp__WSAStartup@8
3>libcurld.lib(http.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
3>libcurld.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
3>libcurld.lib(url.obj) : error LNK2019: unresolved external symbol __imp__closesocket@4 referenced in function _conn_free
3>libcurld.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
3>libcurld.lib(connect.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
3>libcurld.lib(hostthre.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
3>libcurld.lib(select.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
3>libcurld.lib(curl_addrinfo.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
3>libcurld.lib(tftp.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
3>libcurld.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
3>libcurld.lib(ftp.obj) : error LNK2019: unresolved external symbol __imp__WSAGetLastError@0 referenced in function _ftp_parse_url_path
3>libcurld.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
3>libcurld.lib(sendf.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
3>libcurld.lib(connect.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
3>libcurld.lib(hostthre.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
3>libcurld.lib(sendf.obj) : error LNK2019: unresolved external symbol __imp__send@16 referenced in function _Curl_send_plain
3>libcurld.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp__send@16
3>libcurld.lib(sendf.obj) : error LNK2019: unresolved external symbol __imp__recv@16 referenced in function _Curl_recv_plain
3>libcurld.lib(connect.obj) : error LNK2001: unresolved external symbol __imp__recv@16
3>libcurld.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__getsockname@12 referenced in function _Curl_updateconninfo
3>libcurld.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__getsockname@12
3>libcurld.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__getpeername@12 referenced in function _Curl_updateconninfo
3>libcurld.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__ntohs@4 referenced in function _getaddressinfo
3>libcurld.lib(curl_addrinfo.obj) : error LNK2001: unresolved external symbol __imp__ntohs@4
3>libcurld.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__ntohs@4
3>libcurld.lib(socks.obj) : error LNK2001: unresolved external symbol __imp__ntohs@4
3>libcurld.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__getsockopt@20 referenced in function _verifyconnect
3>libcurld.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__setsockopt@20 referenced in function _Curl_sndbufset
3>libcurld.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__connect@12 referenced in function _singleipconnect
3>libcurld.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__socket@12 referenced in function _singleipconnect
3>libcurld.lib(hostthre.obj) : error LNK2001: unresolved external symbol __imp__socket@12
3>libcurld.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__socket@12
3>libcurld.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__bind@12 referenced in function _bindlocal
3>libcurld.lib(tftp.obj) : error LNK2001: unresolved external symbol __imp__bind@12
3>libcurld.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__bind@12
3>libcurld.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__htons@4 referenced in function _bindlocal
3>libcurld.lib(curl_addrinfo.obj) : error LNK2001: unresolved external symbol __imp__htons@4
3>libcurld.lib(ftp.obj) : error LNK2001: unresolved external symbol __imp__htons@4
3>libcurld.lib(socks.obj) : error LNK2001: unresolved external symbol __imp__htons@4
3>libcurld.lib(curl_addrinfo.obj) : error LNK2019: unresolved external symbol __imp__WSASetLastError@4 referenced in function _WspiapiGetAddrInfo@16
3>libcurld.lib(select.obj) : error LNK2001: unresolved external symbol __imp__WSASetLastError@4
3>libcurld.lib(curl_addrinfo.obj) : error LNK2019: unresolved external symbol __imp__inet_ntoa@4 referenced in function _WspiapiLegacyGetAddrInfo@16
3>libcurld.lib(curl_addrinfo.obj) : error LNK2019: unresolved external symbol __imp__htonl@4 referenced in function _WspiapiLegacyGetAddrInfo@16
3>libcurld.lib(curl_addrinfo.obj) : error LNK2019: unresolved external symbol __imp__getservbyname@8 referenced in function _WspiapiLegacyGetAddrInfo@16
3>libcurld.lib(curl_addrinfo.obj) : error LNK2019: unresolved external symbol __imp__inet_addr@4 referenced in function _WspiapiParseV4Address@8
3>libcurld.lib(curl_addrinfo.obj) : error LNK2019: unresolved external symbol __imp__gethostbyname@4 referenced in function _WspiapiQueryDNS@24
3>libcurld.lib(curl_addrinfo.obj) : error LNK2019: unresolved external symbol __imp__gethostbyaddr@12 referenced in function _WspiapiLegacyGetNameInfo@28
3>libcurld.lib(curl_addrinfo.obj) : error LNK2019: unresolved external symbol __imp__getservbyport@8 referenced in function _WspiapiLegacyGetNameInfo@28
3>libcurld.lib(smtp.obj) : error LNK2019: unresolved external symbol __imp__gethostname@8 referenced in function _smtp_connect
3>libcurld.lib(tftp.obj) : error LNK2019: unresolved external symbol __imp__sendto@24 referenced in function _tftp_send_first
3>libcurld.lib(tftp.obj) : error LNK2019: unresolved external symbol __imp__recvfrom@24 referenced in function _tftp_receive_packet
3>libcurld.lib(ftp.obj) : error LNK2019: unresolved external symbol __imp__listen@8 referenced in function _ftp_state_use_port
3>libcurld.lib(ftp.obj) : error LNK2019: unresolved external symbol __imp__accept@12 referenced in function _AllowServerConnect
3>libcurld.lib(select.obj) : error LNK2019: unresolved external symbol ___WSAFDIsSet@8 referenced in function _Curl_socket_ready
3>libcurld.lib(nonblock.obj) : error LNK2019: unresolved external symbol __imp__ioctlsocket@12 referenced in function _curlx_nonblock
In such case all what you need is to link with ws2_32.lib.

Same problem can happen if you are using libcurl with LDAP support. To resolve it just link with wldap32.lib

6 comments:

kiran said...

have been looking for solution so long, thanks, that worked! :)

just find "ws2_32.lib" in your computer and link it [give reference path]

Anonymous said...

Yesss! Additional Dependencies "ws2_32.lib" worked. Thanks so much.

Saravana Kumar said...

Worked! Thank you very much! --Puli

Saravana Kumar said...

Yes! Worked like charm! !!!Important!!!
Do add /MD to use 'msvcrt.lib' if you have lib conflicts problem like --
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other libs; use /NODEFAULTLIB:library
!
Regards!

Saravana Kumar said...

Long time i haven't found this solution! Now it works!
Regards!

Rakesh said...

Thanks..