cURL / Mailing Lists / curl-library / Single Mail

curl-library

RE: building with MSVC

From: David Byron <DByron_at_everdreamcorp.com>
Date: Mon, 23 Feb 2004 14:40:41 -0800

On Mon, 23 Feb 2004, Gisle Vanem wrote:

> I described this a few days ago. It's because include both
> <winsock.h> and <winsock2.h> are included. We should only
> use <winsock2.h> IMHO. That doesn't mean libcurl programs
> must have Winsock 2 at runtime (that is determined by the
> value in WSAStartup().

This makes sense to me. I couldn't get curl to work with plain WinSock but
I didn't try changing win32_init. I'd like to get things building first and
then worry about removing the WinSock 2 requirement next.

> So OTOH src/main.c and include/curl/multi.h needs to be
> patched.

I added ../lib to the include path in src/Makefile.vc6. And I changed
winsock.h to winsock2.h in src/main.c and include/curl/multi.h. Now I get:

        cl.exe /MD /O2 /D "NDEBUG" /I "../lib" /I "../include" /I
"c:\src\cobra\
zlib" /nologo /W3 /GX /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c main.c
main.c
../lib\config-win32.h(35) : warning C4005: 'SIZEOF_CURL_OFF_T' : macro
redefinit
ion
        setup.h(116) : see previous definition of 'SIZEOF_CURL_OFF_T'
main.c(1027) : error C2059: syntax error : 'bad suffix on number'
main.c(1027) : error C2146: syntax error : missing ')' before identifier 'L'
main.c(1027) : error C2059: syntax error : 'bad suffix on number'
NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
Stop.

I have a feeling you (or someone else) has gotten this far before as well.
As I look into this (the redefinition warning), it doesn't look like it
should ever happen. setup.h has a double-include guard and is the only
place I can find that includes config-win32.h. I added a double-include
guard to config-win32.h, but that didn't help, so I added an #ifndef before
defining SIZEOF_CURL_OFF_T. Not sure why the error on line 1027 is
there...More on that later.

The next error is:

        cl.exe /MD /O2 /D "NDEBUG" /P /I "../lib" /I "../include" /I
"c:\src\cob
ra\zlib" /nologo /W3 /GX /D "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
main.c
main.c
../lib\strtoofft.h(41) : fatal error C1017: invalid integer constant
expression
NMAKE : fatal error U1077: 'cl.exe' : return code '0x2'
Stop.

This one really looks like it should work. If instead of #ifndef-protecting
SIZEOF_CURL_OFF_T, I #ifdef and then #undef, I make this go away.

This brings me back to:

        cl /I "../lib" /I "../include" /I "c:\src\cobra\zlib" /nologo /W3
/GX /D
 "WIN32" /D "_CONSOLE" /D "_MBCS" /YX /FD /c /c main.c
main.c
main.c(1027) : error C2059: syntax error : 'bad suffix on number'
main.c(1027) : error C2146: syntax error : missing ')' before identifier 'L'
main.c(1027) : error C2059: syntax error : 'bad suffix on number'
NMAKE : fatal error U1077: 'cl' : return code '0x2'
Stop.

It seems MSVC doesn't like LL. If I change it to plain old L, it compiles
fine. I get this with both MSVC 6 and 7. Any ideas?

This is what happens when I change to plain old L and link:

        link.exe /incremental:no /libpath:"../lib" /nologo
/libpath:"c:\src\cobra\zlib" /out:curl.exe /subsystem:console /machine:I386
/LIBPATH:"c:\src\cobra\openssl/out32" ws2_32.lib libcurl.lib winmm.lib
zlib.lib libeay32.lib ssleay32.lib gdi32.lib hugehelp.obj writeout.obj
urlglob.obj getpass.obj homedir.obj main.obj
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _isdigit already defined in
LIBC.lib(_ctype.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strtol already defined in
LIBC.lib(strtol.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _realloc already defined in
LIBC.lib(realloc.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _malloc already defined in
LIBC.lib(malloc.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _sprintf already defined in
LIBC.lib(sprintf.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _free already defined in
LIBC.lib(free.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fputc already defined in
LIBC.lib(fputc.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fwrite already defined in
LIBC.lib(fwrite.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strstr already defined in
LIBC.lib(strstr.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strchr already defined in
LIBC.lib(strchr.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _sscanf already defined in
LIBC.lib(sscanf.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _time already defined in
LIBC.lib(time.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fclose already defined in
LIBC.lib(fclose.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fread already defined in
LIBC.lib(fread.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fopen already defined in
LIBC.lib(fopen.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _getenv already defined in
LIBC.lib(getenv.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _abort already defined in
LIBC.lib(abort.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _isalpha already defined in
LIBC.lib(_ctype.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strncmp already defined in
LIBC.lib(strncmp.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _tolower already defined in
LIBC.lib(tolower.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _isupper already defined in
LIBC.lib(_ctype.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _isspace already defined in
LIBC.lib(_ctype.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _gmtime already defined in
LIBC.lib(gmtime.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _localtime already defined in
LIBC.lib(localtim.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fprintf already defined in
LIBC.lib(fprintf.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strncpy already defined in
LIBC.lib(strncpy.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fflush already defined in
LIBC.lib(fflush.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _atoi already defined in
LIBC.lib(atox.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strtoul already defined in
LIBC.lib(strtol.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _strrchr already defined in
LIBC.lib(strrchr.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _toupper already defined in
LIBC.lib(toupper.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _memmove already defined in
LIBC.lib(memmove.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __errno already defined in
LIBC.lib(mterrno.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fgets already defined in
LIBC.lib(fgets.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _fputs already defined in
LIBC.lib(fputs.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: _isxdigit already defined in
LIBC.lib(_ctype.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __strdup already defined in
LIBC.lib(strdup.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __open already defined in
LIBC.lib(open.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __close already defined in
LIBC.lib(close.obj)
MSVCRT.lib(MSVCRT.dll) : error LNK2005: __read already defined in
LIBC.lib(read.obj)
LINK : warning LNK4098: defaultlib "MSVCRT" conflicts with use of other
libs; use /NODEFAULTLIB:library
LINK : warning LNK4098: defaultlib "LIBCMT" conflicts with use of other
libs; use /NODEFAULTLIB:library
main.obj : error LNK2001: unresolved external symbol _curlx_strtoll
libcurl.lib(ssluse.obj) : error LNK2001: unresolved external symbol __ftol2
libcurl.lib(connect.obj) : error LNK2001: unresolved external symbol __ftol2
libcurl.lib(progress.obj) : error LNK2001: unresolved external symbol
__ftol2
libcurl.lib(transfer.obj) : error LNK2001: unresolved external symbol
_strtoofft

libcurl.lib(ftp.obj) : error LNK2001: unresolved external symbol _strtoofft
curl.exe : fatal error LNK1120: 3 unresolved externals
NMAKE : fatal error U1077: 'link.exe' : return code '0x460'

I think I can figure out the duplicate lib stuff. Not sure what the deal is
with strtoofft.

I can send a patch with the progress I've made so far, but it seems best to
get things working first.

Thanks for your help.

-DB
Received on 2004-02-23