HTTP downloading from R1Q2- which version of libcurl to use?

Discuss programming topics for the various GPL'd game engine sources.
Knightmare
Posts: 63
Joined: Thu Feb 09, 2012 1:55 am

HTTP downloading from R1Q2- which version of libcurl to use?

Post by Knightmare »

I've been looking at adding the HTTP auto-downloading feature from R1Q2 to my engine, but R1Q2's source (latest b8102 version) omits the libcurl headers and static library needed for this feature. Has anyone here tried to add this and run into this problem?

I was wondering if I could just take any version of libcurl and compile it into a static library and link with it. For example, the one included with the Doom3 source.
Spike
Posts: 2914
Joined: Fri Nov 05, 2004 3:12 am
Location: UK
Contact:

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by Spike »

try it?
most libs aim for backwards compatibility, or rename things where that can't be achieved.
r00k
Posts: 1111
Joined: Sat Nov 13, 2004 10:39 pm

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by r00k »

I ported Warsow's libcurl-download code to netQuake, with very little adjustments.
And since warsow is based on Quake2, it might work even easier for you.
Jay Dolan
Posts: 59
Joined: Tue Jan 22, 2008 7:16 pm
Location: Naples, FL
Contact:

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by Jay Dolan »

Uh, what difference does it make? Once your implementation hits the wire, HTTP 1.1 takes over. It's a spec. Makes zero difference what version of CURL (or any other client library) you use :P

Edit: I see -- you're hoping to basically copy/paste his implementation into your project. Well, in that case, because of the maturity of libCURL, I think you'll be fine with the latest stable release. Their API hasn't changed dramatically in a long, long time (like 10 years).
qbism
Posts: 1236
Joined: Thu Nov 04, 2004 5:51 am
Contact:

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by qbism »

libcurl.lib included with q2pro on github might work.
Knightmare
Posts: 63
Joined: Thu Feb 09, 2012 1:55 am

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by Knightmare »

I got the libcurl from Doom3 compiled into a lib. It was easy enough, as a project file for VS2003 is included.

I'm just intending to copy/paste this as a quick addition to KMQ2. I've gotten a few requests from people who use KMQ2 as a multiplayer client to add HTTP download support, and I don't want to devote much time to it, as there are other features I'd rather work on.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by revelator »

If you want i just compiled the latest version of libcurl for msvc :)
Productivity is a state of mind.
Knightmare
Posts: 63
Joined: Thu Feb 09, 2012 1:55 am

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by Knightmare »

Just got that version (7.37.0) compiled into a .lib as well.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by revelator »

Ok m8 :) old one from Doom3 caused the server list to come up empty but after upgrading it works again.
Productivity is a state of mind.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by revelator »

Even found a C++ wrapper which might work out nicely for Doom3.

https://github.com/JosephP91/curlcpp
Productivity is a state of mind.
Knightmare
Posts: 63
Joined: Thu Feb 09, 2012 1:55 am

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by Knightmare »

I got the HTTP code from R1Q2 merged in, which was quite a bit of a task, as cl_http.c isn't very portable.

But I'm getting lots of linker errors with libcurl 7.37.0:

Code: Select all

MSVCRT.lib(MSVCR90.dll) : error LNK2005: _calloc already defined in LIBCMT.lib(calloc.obj)
MSVCRT.lib(MSVCR90.dll) : error LNK2005: _realloc already defined in LIBCMT.lib(realloc.obj)
.
.
MSVCRT.lib(MSVCR90.dll) : error LNK2005: __strnicmp already defined in LIBCMT.lib(strnicmp.obj)
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library
libcurl_r.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__WSAIoctl@36 referenced in function _tcpkeepalive
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_unbind_s referenced in function _Curl_ldap
This version (7.37.0) I compiled from the command line using nmake with the vc10 makefile. Anybody got a VS2008 project file that works?

Libcurl 7.11.1 I was able to compile and link with (it has a VS2003 project I converted to 2008), but it doesn't support the curl_easy_strerror() function used by the R1Q2 code.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by revelator »

add libcmt.lib to ignored libraries ;) also link curl with the static msvc runtime eg. /MT not /MD
Productivity is a state of mind.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by revelator »

Oh btw the reson why curl_easy is not working is that you need to remove a few lines in curl.h.

Code: Select all

/*
 * libcurl external API function linkage decorations.
 */

#ifdef CURL_STATICLIB
#  define CURL_EXTERN
#elif defined(WIN32) || defined(_WIN32) || defined(__SYMBIAN32__)
#  if defined(BUILDING_LIBCURL)
#    define CURL_EXTERN  __declspec(dllexport)
#  else
#    define CURL_EXTERN  __declspec(dllimport)
#  endif
#elif defined(BUILDING_LIBCURL) && defined(CURL_HIDDEN_SYMBOLS)
#  define CURL_EXTERN CURL_EXTERN_SYMBOL
#else
#  define CURL_EXTERN
#endif
change it to

Code: Select all

/*
 * libcurl external API function linkage decorations.
 */
#if defined(WIN32) || defined(_WIN32)
#  define CURL_EXTERN
#endif
for static linking.

you could also add CURL_STATICLIB to the preprocessor definitions and leave curl.h as it is.
Productivity is a state of mind.
Knightmare
Posts: 63
Joined: Thu Feb 09, 2012 1:55 am

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by Knightmare »

Adding libcmt to the ignore list takes care of the already defined errors, but it doesn't fix the unresolved external symbol errors:

Code: Select all

libcurl_r.lib(connect.obj) : error LNK2019: unresolved external symbol __imp__WSAIoctl@36 referenced in function _tcpkeepalive
libcurl_r.lib(curl_addrinfo.obj) : error LNK2019: unresolved external symbol __imp__freeaddrinfo@4 referenced in function _Curl_getaddrinfo_ex
libcurl_r.lib(curl_addrinfo.obj) : error LNK2019: unresolved external symbol __imp__getaddrinfo@16 referenced in function _Curl_getaddrinfo_ex>libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_unbind_s referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_msgfree referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_next_entry referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ber_free referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_next_attribute referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_memfree referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_value_free_len referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_get_values_len referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_first_attribute referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_get_dn referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_first_entry referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_search_s referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_simple_bind_s referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_init referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_set_option referenced in function _Curl_ldap
libcurl_r.lib(ldap.obj) : error LNK2019: unresolved external symbol __imp__ldap_err2string referenced in function _Curl_ldap
It also adds some unresolved external symbol errors with libjpeg and libpng.

The problem with curl_easy_strerror() is that it simply isn't in the older 7.11.1 version (not anywhere in the source).

It looks like I'm gonna need a VS2008 project file for libcurl 7.37.0 so I can try tweaking some configuration options.
revelator
Posts: 2621
Joined: Thu Jan 24, 2008 12:04 pm
Location: inside tha debugger

Re: HTTP downloading from R1Q2- which version of libcurl to

Post by revelator »

I have it compiled and ready to go and curl_easy is in the curl sources ;) believe me its a library export.

http://sourceforge.net/projects/cbadvan ... z/download

I use it In Doom3 which also uses curl_easy :)

edit: Ah you ment that specific function oki.

Also included is the c++ wrapper libraries for curl but you probably wont need those in a C based engine.

Also got some undefined crap untill i played a bit with the project settings now it works just fine, ill investigate the steps i took and post them back here.

Edit again: ok i see now you are linking to the dll version, that wont work with the modified curl.h from me its static only. If you insist on using the dll leave curl.h alone but it works just fine if you link it statically.
Thing with the static lib is that you need to know what windows libraries curl depends on and add them to the linker as well, those are ws2_32.lib wldap32.lib advapi32.lib normaliz.lib some of them are probably allready in the linker but double check just in case. My bet would be that you are missing ws2_32.lib and wldap32.lib.
Last edited by revelator on Mon Jun 30, 2014 2:54 am, edited 2 times in total.
Productivity is a state of mind.
Post Reply