Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Can't build Python extension with mingw32 on Windows #59520

Closed
cmcqueen1975 mannequin opened this issue Jul 10, 2012 · 10 comments
Closed

Can't build Python extension with mingw32 on Windows #59520

cmcqueen1975 mannequin opened this issue Jul 10, 2012 · 10 comments
Labels
extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error

Comments

@cmcqueen1975
Copy link
Mannequin

cmcqueen1975 mannequin commented Jul 10, 2012

BPO 15315
Nosy @loewis, @amauryfa
Dependencies
  • bpo-12641: Remove -mno-cygwin from distutils
  • Superseder
  • bpo-45538: MinGW is unsupported - close all open issues and list them here.
  • Files
  • log.txt
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-10-20.12:40:56.611>
    created_at = <Date 2012-07-10.04:52:02.584>
    labels = ['extension-modules', 'type-bug']
    title = "Can't build Python extension with mingw32 on Windows"
    updated_at = <Date 2021-10-21.09:59:14.426>
    user = 'https://bugs.python.org/cmcqueen1975'

    bugs.python.org fields:

    activity = <Date 2021-10-21.09:59:14.426>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-10-20.12:40:56.611>
    closer = 'iritkatriel'
    components = ['Extension Modules']
    creation = <Date 2012-07-10.04:52:02.584>
    creator = 'cmcqueen1975'
    dependencies = ['12641']
    files = ['30580']
    hgrepos = []
    issue_num = 15315
    keywords = []
    message_count = 10.0
    messages = ['165159', '165160', '165161', '165174', '165176', '165177', '165179', '165212', '191106', '191115']
    nosy_count = 6.0
    nosy_names = ['loewis', 'amaury.forgeotdarc', 'rpetrov', 'cmcqueen1975', 'python-dev', 'adityaatluri']
    pr_nums = []
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = '45538'
    type = 'behavior'
    url = 'https://bugs.python.org/issue15315'
    versions = ['Python 3.3']

    @cmcqueen1975
    Copy link
    Mannequin Author

    cmcqueen1975 mannequin commented Jul 10, 2012

    I'm trying this with my 'cobs' Python package:

    c:\Python33\python.exe setup.py build --compiler=mingw32 bdist_msi
    

    With Python 3.3 beta, it fails with an exception:

    ValueError: Unknown MS Compiler version 1600
    

    It works with Python 3.2.

    @cmcqueen1975 cmcqueen1975 mannequin added the extension-modules C modules in the Modules dir label Jul 10, 2012
    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented Jul 10, 2012

    New changeset eee92b9ac4ad by Martin v. Löwis in branch 'default':
    Issue bpo-15315: Support VS 2010 in distutils cygwincompiler.
    http://hg.python.org/cpython/rev/eee92b9ac4ad

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jul 10, 2012

    This should now be fixed in the repository. It would be good if you could manually apply the change to your installation, and report whether it works.

    @cmcqueen1975
    Copy link
    Mannequin Author

    cmcqueen1975 mannequin commented Jul 10, 2012

    That's definitely an improvement. It gets further, but on my PC, the compile fails:

    ...
    c:/mingw/bin/../lib/gcc/mingw32/4.5.0/../../../../mingw32/bin/ld.exe: cannot find -lmsvcr100
    collect2: ld returned 1 exit status
    error: command 'gcc' failed with exit status 1

    I'll have to see if I can get the required library I guess.

    @cmcqueen1975
    Copy link
    Mannequin Author

    cmcqueen1975 mannequin commented Jul 10, 2012

    I downloaded the latest MinGW, and now it tells me:

    ...
    c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -IC:\Python33\include -IC:\Python33\PC -c python3/src/_cobs_ext.c -o bui
    ld\temp.win32-3.3\Release\python3\src\_cobs_ext.o
    cc1.exe: error: unrecognized command line option '-mno-cygwin'
    error: command 'gcc' failed with exit status 1

    @cmcqueen1975
    Copy link
    Mannequin Author

    cmcqueen1975 mannequin commented Jul 10, 2012

    It sounds as though the option '-mno-cygwin' is related to issue bpo-12641.

    Does that mean I need to find a version of MinGW that is old enough to support the option '-mno-cygwin', but new enough to include a library for msvcr100?

    @loewis
    Copy link
    Mannequin

    loewis mannequin commented Jul 10, 2012

    I'm not a Cygwin user myself, so it would be good if you could figure this out somehow. Feel free to ask on Cygwin lists how this is supposed to work. Our requirement is that the resulting pyd needs to link with msvcr100.dll. It may well be that *no* version of Cygwin ever supported this, in which case we should drop Cygwin support from Python 3.3.

    @cmcqueen1975
    Copy link
    Mannequin Author

    cmcqueen1975 mannequin commented Jul 10, 2012

    I've succeeded in building an extension for Python 3.3 (at least, on Windows XP, 32-bit; haven't tried any 64-bit), by the hack of copying libmsvcr100.a from a recent MinGW release (2012042) into an older MinGW release (20101030).

    I haven't looked at MinGW releases to see if I can find one that supports both the -mno-cygwin option and msvcr100.

    I guess the best solution for this is to resolve issue bpo-12641 for Python 3.3.

    @ezio-melotti ezio-melotti added the type-bug An unexpected behavior, bug, or error label Sep 11, 2012
    @adityaatluri
    Copy link
    Mannequin

    adityaatluri mannequin commented Jun 14, 2013

    I have found a hack for the issue.
    First, install Microsoft Visual C++ 2010 Redistributable Package.
    Second, copy the msvcr100.dll to C:\Python33\libs.

    Reason: During compilation, the directory for linking is C:\Python44\libs. Both -lpython and -lmsvcr100 are pointed to the same location. So, they have to be in the same directory.

    I have another problem here.
    The log is attached. Is there a change in functions and objects in building extensions in C from 2.7 and 3.3?

    @amauryfa
    Copy link
    Member

    Aditya, python3 changed the API to create modules. See bpo-18210.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    extension-modules C modules in the Modules dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants