Author Topic: Compile Errors and Resolutions  (Read 5040 times)

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Compile Errors and Resolutions
« on: March 07, 2007, 12:26:43 AM »
Ok, I hate it when I run into a compile error and have to scour all over the Internet to find what libraries or defines are necessary, so I'm starting up this thread to paste my errors and what I've done to fix them.


Error:

Linking...
curltest1.obj : error LNK2019: unresolved external symbol __imp__curl_easy_cleanup referenced in function _main
curltest1.obj : error LNK2019: unresolved external symbol __imp__curl_easy_setopt referenced in function _main
curltest1.obj : error LNK2019: unresolved external symbol __imp__curl_easy_init referenced in function _main
Debug/cURLTest.exe : fatal error LNK1120: 3 unresolved externals

Solution:

#define CURL_STATICLIB before including curl.h (or add CURL_STATICLIB to the preprocessor defines in the C/C++ section of the project properties in visual studio)


Error:

Linking...
curllib_mtd.lib(easy.obj) : error LNK2019: unresolved external symbol __imp__WSACleanup@0 referenced in function _win32_init
curllib_mtd.lib(telnet.obj) : error LNK2019: unresolved external symbol __imp__WSACleanup@0 referenced in function _printsub
curllib_mtd.lib(easy.obj) : error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function _win32_init
curllib_mtd.lib(telnet.obj) : error LNK2019: unresolved external symbol __imp__WSAStartup@8 referenced in function _printsub
curllib_mtd.lib(ftp.obj) : error LNK2019: unresolved external symbol __imp__closesocket@4 referenced in function _ftp_state_use_port
curllib_mtd.lib(http.obj) : error LNK2019: unresolved external symbol __imp__closesocket@4 referenced in function _Curl_https_connecting
curllib_mtd.lib(connect.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
curllib_mtd.lib(url.obj) : error LNK2019: unresolved external symbol __imp__closesocket@4 referenced in function _conn_free
curllib_mtd.lib(transfer.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
curllib_mtd.lib(hostthre.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
curllib_mtd.lib(multi.obj) : error LNK2001: unresolved external symbol __imp__closesocket@4
curllib_mtd.lib(getinfo.obj) : error LNK2019: unresolved external symbol __imp__recv@16 referenced in function _Curl_getinfo
curllib_mtd.lib(sendf.obj) : error LNK2019: unresolved external symbol __imp__recv@16 referenced in function _curl_slist_append
curllib_mtd.lib(inet_ntop.obj) : error LNK2019: unresolved external symbol __imp__WSASetLastError@4 referenced in function _Curl_inet_ntop
curllib_mtd.lib(hostthre.obj) : error LNK2001: unresolved external symbol __imp__WSASetLastError@4
curllib_mtd.lib(inet_ntop.obj) : error LNK2019: unresolved external symbol __imp__inet_ntoa@4 referenced in function _inet_ntop4
curllib_mtd.lib(hostthre.obj) : error LNK2019: unresolved external symbol __imp__WSAGetLastError@0 referenced in function _Curl_getaddrinfo
curllib_mtd.lib(telnet.obj) : error LNK2019: unresolved external symbol __imp__WSAGetLastError@0 referenced in function _printoption
curllib_mtd.lib(connect.obj) : error LNK2001: unresolved external symbol __imp__WSAGetLastError@0
curllib_mtd.lib(hostthre.obj) : error LNK2019: unresolved external symbol __imp__gethostbyname@4 referenced in function _Curl_getaddrinfo
curllib_mtd.lib(hostthre.obj) : error LNK2019: unresolved external symbol __imp__inet_addr@4 referenced in function _Curl_getaddrinfo
curllib_mtd.lib(ftp.obj) : error LNK2019: unresolved external symbol __imp__inet_addr@4 referenced in function _ftp_state_post_retr_size
curllib_mtd.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__inet_addr@4 referenced in function _Curl_store_ip_addr
curllib_mtd.lib(hostthre.obj) : error LNK2019: unresolved external symbol __imp__socket@12 referenced in function _init_resolve_thread
curllib_mtd.lib(ftp.obj) : error LNK2019: unresolved external symbol __imp__socket@12 referenced in function _ftp_state_mdtm_resp
curllib_mtd.lib(connect.obj) : error LNK2001: unresolved external symbol __imp__socket@12
curllib_mtd.lib(hostip4.obj) : error LNK2019: unresolved external symbol __imp__htons@4 referenced in function _Curl_he2ai
curllib_mtd.lib(socks.obj) : error LNK2019: unresolved external symbol __imp__htons@4 referenced in function _Curl_SOCKS5
curllib_mtd.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__htons@4 referenced in function _bindlocal
curllib_mtd.lib(sendf.obj) : error LNK2019: unresolved external symbol __imp__send@16 referenced in function _Curl_plain_send
curllib_mtd.lib(telnet.obj) : error LNK2001: unresolved external symbol __imp__send@16
curllib_mtd.lib(timeval.obj) : error LNK2019: unresolved external symbol __imp__timeGetTime@0 referenced in function _gettimeofday
curllib_mtd.lib(tftp.obj) : error LNK2019: unresolved external symbol __imp__bind@12 referenced in function _Curl_tftp_connect
curllib_mtd.lib(ftp.obj) : error LNK2019: unresolved external symbol __imp__bind@12 referenced in function _ftp_state_post_retr_size
curllib_mtd.lib(connect.obj) : error LNK2001: unresolved external symbol __imp__bind@12
curllib_mtd.lib(tftp.obj) : error LNK2019: unresolved external symbol __imp__recvfrom@24 referenced in function _Curl_tftp
curllib_mtd.lib(tftp.obj) : error LNK2019: unresolved external symbol __imp__sendto@24 referenced in function _tftp_send_first
curllib_mtd.lib(ftp.obj) : error LNK2019: unresolved external symbol __imp__listen@8 referenced in function _ftp_state_use_port
curllib_mtd.lib(ftp.obj) : error LNK2019: unresolved external symbol __imp__ntohs@4 referenced in function _ftp_state_use_port
curllib_mtd.lib(socks.obj) : error LNK2001: unresolved external symbol __imp__ntohs@4
curllib_mtd.lib(connect.obj) : error LNK2001: unresolved external symbol __imp__ntohs@4
curllib_mtd.lib(ftp.obj) : error LNK2019: unresolved external symbol __imp__getsockname@12 referenced in function _ftp_state_use_port
curllib_mtd.lib(connect.obj) : error LNK2001: unresolved external symbol __imp__getsockname@12
curllib_mtd.lib(ftp.obj) : error LNK2019: unresolved external symbol __imp__accept@12 referenced in function _AllowServerConnect
curllib_mtd.lib(select.obj) : error LNK2019: unresolved external symbol ___WSAFDIsSet@8 referenced in function _Curl_select
curllib_mtd.lib(select.obj) : error LNK2019: unresolved external symbol __imp__select@20 referenced in function _Curl_select
curllib_mtd.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__ioctlsocket@12 referenced in function _Curl_nonblock
curllib_mtd.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__getsockopt@20 referenced in function _verifyconnect
curllib_mtd.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__connect@12 referenced in function _singleipconnect
curllib_mtd.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__setsockopt@20 referenced in function _tcpnodelay
curllib_mtd.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__getprotobyname@4 referenced in function _tcpnodelay
Debug/cURLTest.exe : fatal error LNK1120: 27 unresolved externals


Solution:
Add ws2_32.lib and winmm.lib to the additional dependencies in linker/input

Eiii

  • Autococker
  • Posts: 4595
Re: Compile Errors and Resolutions
« Reply #1 on: March 07, 2007, 02:02:33 AM »
Developing for Linux sounds like fun.

XtremeBain

  • Developer
  • Autococker
  • Posts: 1470
Re: Compile Errors and Resolutions
« Reply #2 on: March 07, 2007, 02:15:56 AM »
Developing for Linux sounds like fun.
It is, too bad jitspoe is having such a mess of a time working on Windows in this topic ;)

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Compile Errors and Resolutions
« Reply #3 on: March 07, 2007, 02:45:45 AM »
Linux is twice as frustrating.  Gcc will crap itself if you do something simple like, *gasp* pass a char * to a function that accepts const unsigned char *, but it won't bother to tell you there are like 10 libraries you still need to link.  It just fails to load your library at runtime with no explanation of why.

You know what, don't even get me started.   :P

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Compile Errors and Resolutions
« Reply #4 on: March 07, 2007, 03:19:07 PM »
Problem 1 (using sample code from MSDN):
E:\projects\testing\junk\proxyinfo\proxyinfo.c(7) : error C2065: 'INTERNET_PER_CONN_OPTION_LIST' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(7) : error C2146: syntax error : missing ';' before identifier 'List'
E:\projects\testing\junk\proxyinfo\proxyinfo.c(7) : error C2065: 'List' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(8) : error C2065: 'INTERNET_PER_CONN_OPTION' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(8) : error C2146: syntax error : missing ';' before identifier 'Option'
E:\projects\testing\junk\proxyinfo\proxyinfo.c(8) : error C2065: 'Option' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(8) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(9) : error C2143: syntax error : missing ';' before 'type'
E:\projects\testing\junk\proxyinfo\proxyinfo.c(11) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(11) : error C2224: left of '.dwOption' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(11) : error C2065: 'INTERNET_PER_CONN_AUTOCONFIG_URL' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(12) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(12) : error C2224: left of '.dwOption' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(12) : error C2065: 'INTERNET_PER_CONN_AUTODISCOVERY_FLAGS' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(13) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(13) : error C2224: left of '.dwOption' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(13) : error C2065: 'INTERNET_PER_CONN_FLAGS' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(14) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(14) : error C2224: left of '.dwOption' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(14) : error C2065: 'INTERNET_PER_CONN_PROXY_BYPASS' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(15) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(15) : error C2224: left of '.dwOption' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(15) : error C2065: 'INTERNET_PER_CONN_PROXY_SERVER' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(17) : error C2224: left of '.dwSize' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(18) : error C2224: left of '.pszConnection' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(19) : error C2224: left of '.dwOptionCount' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(20) : error C2224: left of '.dwOptionError' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(21) : error C2224: left of '.pOptions' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(23) : error C2065: 'INTERNET_OPTION_PER_CONNECTION_OPTION' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(23) : error C2065: 'nSize' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(26) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(26) : error C2224: left of '.Value' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(27) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(27) : error C2224: left of '.Value' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(29) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(29) : error C2224: left of '.Value' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(29) : error C2065: 'PROXY_TYPE_AUTO_PROXY_URL' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(32) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(32) : error C2224: left of '.Value' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(32) : error C2065: 'PROXY_TYPE_AUTO_DETECT' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(35) : error C2275: 'INTERNET_VERSION_INFO' : illegal use of this type as an expression
        f:\program files\microsoft visual studio\vc98\include\wininet.h(322) : see declaration of 'INTERNET_VERSION_INFO'
E:\projects\testing\junk\proxyinfo\proxyinfo.c(35) : error C2146: syntax error : missing ';' before identifier 'Version'
E:\projects\testing\junk\proxyinfo\proxyinfo.c(35) : error C2065: 'Version' : undeclared identifier
E:\projects\testing\junk\proxyinfo\proxyinfo.c(40) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(40) : error C2224: left of '.Value' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(41) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(41) : error C2224: left of '.Value' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(41) : error C2198: 'GlobalFree' : too few actual parameters
E:\projects\testing\junk\proxyinfo\proxyinfo.c(43) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(43) : error C2224: left of '.Value' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(44) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(44) : error C2224: left of '.Value' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(44) : error C2198: 'GlobalFree' : too few actual parameters
E:\projects\testing\junk\proxyinfo\proxyinfo.c(46) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(46) : error C2224: left of '.Value' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(47) : error C2109: subscript requires array or pointer type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(47) : error C2224: left of '.Value' must have struct/union type
E:\projects\testing\junk\proxyinfo\proxyinfo.c(47) : error C2198: 'GlobalFree' : too few actual parameters

Solution:
Wininet.h is obsolete or not included.  Use a newer version of visual studio (or I think you can get a newer version with the platform SDK).



Problem 2:

c:\Projects\testing\proxyinfo\proxyinfo.c(35) : error C2275: 'INTERNET_VERSION_INFO' : illegal use of this type as an expression
        c:\Program Files\Microsoft Visual Studio .NET\Vc7\PlatformSDK\Include\WinInet.h(430) : see declaration of 'INTERNET_VERSION_INFO'
c:\Projects\testing\proxyinfo\proxyinfo.c(35) : error C2146: syntax error : missing ';' before identifier 'Version'
c:\Projects\testing\proxyinfo\proxyinfo.c(35) : error C2144: syntax error : '<Unknown>' should be preceded by '<Unknown>'
c:\Projects\testing\proxyinfo\proxyinfo.c(35) : error C2144: syntax error : '<Unknown>' should be preceded by '<Unknown>'
c:\Projects\testing\proxyinfo\proxyinfo.c(35) : error C2143: syntax error : missing ';' before 'identifier'
c:\Projects\testing\proxyinfo\proxyinfo.c(35) : error C2065: 'Version' : undeclared identifier

Solution:
This isn't standard C code.  Version needs to be declared at the top of the function (or compile it as cpp).  Just relocate this line to the top: "INTERNET_VERSION_INFO      Version;"



Problem 3:
Linking...
proxyinfo.obj : error LNK2019: unresolved external symbol __imp__InternetQueryOptionA@16 referenced in function _main
Debug/proxyinfo.exe : fatal error LNK1120: 1 unresolved externals

Solution:
wininet.lib needs to be included in the linker input for the project properties.

Cobo

  • Autococker
  • Posts: 1362
Re: Compile Errors and Resolutions
« Reply #5 on: March 07, 2007, 03:30:54 PM »
So you are having all this problems as you post them, or are you remembering them?

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Compile Errors and Resolutions
« Reply #6 on: March 07, 2007, 03:35:35 PM »
I have an exceptional memory and can recite compile errors down to the line number.

Nah, I'm just posting what I get as I get it in hopes that I can help out some desperate programmer googling for solutions.

jitspoe

  • Administrator
  • Autococker
  • Posts: 18802
Re: Compile Errors and Resolutions
« Reply #7 on: April 10, 2007, 08:43:22 PM »
Problem:
Code: [Select]
c:\program files\microsoft platform sdk\include\dispex.h(944) : error C2061: syntax error : identifier 'DWORD_PTR'
Solution:
(Install the platform SDK if you haven't)
Move the include priority of the platform sdk files above the old visual studio\VC98\Include directories:
Tools|Options|Directories



Problem:
Code: [Select]
Wbemuuid.lib(wbemcli_i.obj) : fatal error LNK1103: debugging information corrupt; recompile module
Solution:
The wbemuuid.lib is compiled with a newer (or older) compiler.  Obtain a lib file that matches what you're compiling with.

MSVC 6 version attached:
« Last Edit: April 10, 2007, 09:46:12 PM by jitspoe »