Web lists-archives.com

Re: [Mingw-users] Using mingw's libpng?




On 6 July 2016 at 20:18, mathog <mathog@xxxxxxxxxxx> wrote:
> On 06-Jul-2016 10:29, Eli Zaretskii wrote:
>> On Windows, there are
>> at least a dozen of different versions of C runtime, and Python
>> specifically is built with MSVC, so almost certainly uses a runtime
>> different from the MinGW default (which is msvcrt.dll).
>
> This was evident once I built a zip file to run on another person's
> machine.
> Both msvcrt.dll and msvcr90.dll were needed.

As Eli said, Python uses the MSVC CRT (msvcr90.dll in your case - it
depends on the Python version). Building Python extensions should
normally only be done with the same C compiler as Python used, to
avoid precisely this sort of issue. In this case, there are *three*
pieces of code involved, Python itself, the extension (the .pyd file)
and the PNG library. They should all be built with MSVC.

If you are very, very, careful, you can build Python extensions with
mingw, but you have to take care not to pass CRT data (such as FILE
pointers) across the DLL boundaries. Clearly this care isn't being
taken here. Probably because libpng doesn't expose a "safe" API that
uses a filename rather than a FILE*. So the extension author probably
had little choice. The decision is reasonable, as mixing compilers
isn't supported anyway, as you've found out.

If you want to go down this route (again, not advised and not
supported!) then your best bet would be to build the extension with
mingw, and statically link a copy of libpng that was also built with
mingw. The Python-extension boundary is designed to be "relatively"
safe in this situation - it's not too likely you'll experience
crashes. You will still need both CRTs installed on the machines that
use the code.

Paul

------------------------------------------------------------------------------
Attend Shape: An AT&T Tech Expo July 15-16. Meet us at AT&T Park in San
Francisco, CA to explore cutting-edge tech and listen to tech luminaries
present their vision of the future. This family event has something for
everyone, including kids. Get more information and register today.
http://sdm.link/attshape
_______________________________________________
MinGW-users mailing list
MinGW-users@xxxxxxxxxxxxxxxxxxxxx

This list observes the Etiquette found at 
http://www.mingw.org/Mailing_Lists.
We ask that you be polite and do the same.  Disregard for the list etiquette may cause your account to be moderated.

_______________________________________________
You may change your MinGW Account Options or unsubscribe at:
https://lists.sourceforge.net/lists/listinfo/mingw-users
Also: mailto:mingw-users-request@xxxxxxxxxxxxxxxxxxxxx?subject=unsubscribe