curl-and-python

Re: Windows builds

From: Gisle Vanem <gvanem_at_yahoo.no>
Date: Wed, 18 Dec 2013 21:20:15 +0100

"Oleg Pudeyev" <oleg+pycurl_at_bsdpower.com> wrote:

> "Gisle Vanem" <gvanem_at_yahoo.no> wrote:
>
>> It would be much easier if setup.py could link against the import-lib
>> of libcurl. As it is written now (static libcurl.lib), it must link
>> with all the external libs libcurl depends on. E.g. gdi32.lib,
>> wldap32.lib, winmm.lib etc.
>
> Which package are you using that has a libcurl_imp.lib?

All or most of them AFAICS. No package AFAIK specifies an
import-lib named libcurl.lib. The FAQ (and also some curl lib/makefiles, a VC
project-file and the horrid ugly mess in lib/Makefile.vc*), specifies
libcurl_imp.lib (and libcurld_imp.lib for the debug version). From the
FAQ 5.7:
       MSVC (release): libcurl.lib libcurl_imp.lib
       MSVC (debug): libcurld.lib libcurld_imp.lib
       Borland: libcurl.lib libcurl_imp.lib

Was your intention that pycurl.pyd should use libcurl as a DLL or
a static lib?

> When I built libcurl from source I got a bunch of different editions
> under build directory. As you can see in winbuild.py, I selected the
> edition I wanted via --curl-dir. If that edition is a DLL, pycurl will
> link against the libcurl DLL.

But the suffix '_imp.lib' is important. I've not used winbuild.py, but
setup.py only states libcurl.lib (static). Which is not so okay.

> gdi32.lib etc. are all standard windows libraries and included by
> default in command lines generated by visual studio, so trying to link
> against them should be harmless.

But no curl-functions need such functions. gdi32.lib is only needed
when a static OpenSSL lib is used. Check with 'link -verbose' to see
what the linker needs from where.
 
>> The "-D_WIN32_WINNT=0x0501" should IMHO be default since inet_ntop()
>> is not present in ws2_32.dll on Win-XP. Only Vista+.
>
> Good point, I forgot about that. But I will add an option to change its
> value for people who want to get the newer functionality.

The value of '_WIN32_WINNT' you mean? It would be better to always use
a private pycurl_inet_ntop(). The inet_ntop() in Vista+ doesn't improve address-
printing over WSAAddressToString(). Except maybe for non-AF_INET/AF_INET6.
But such addresses would probably not occurs in pycurl.

BTW. pycurl_inet_ntop() didn't compile. A patch:

--- a/pycurl.c 2013-12-18 10:20:30 +0000
+++ b/pycurl.c 2013-12-18 20:16:31 +0000
@@ -4990,14 +4990,14 @@
     if (family == AF_INET6) {
         struct sockaddr_in6 sa6;
         memset(&sa6, 0, sizeof(sa6));
- sa6.sa_family = AF_INET6;
+ sa6.sin6_family = AF_INET6;
         memcpy(&sa6.sin6_addr, addr, sizeof(sa6.sin6_addr));
         sa = (SOCKADDR*) &sa6;
         sa_len = sizeof(sa6);
     } else if (family == AF_INET) {
         struct sockaddr_in sa4;
         memset(&sa4, 0, sizeof(sa4));
- sa4.sa_family = AF_INET;
+ sa4.sin_family = AF_INET;
         memcpy(&sa4.sin_addr, addr, sizeof(sa4.sin_addr));
         sa = (SOCKADDR*) &sa4;
         sa_len = sizeof(sa4);

---------

'struct sockaddr_inX' doesn't have 'sa_family'.

--gv
_______________________________________________
http://cool.haxx.se/cgi-bin/mailman/listinfo/curl-and-python
Received on 2013-12-18