classification
Title: Bad value for Mingw32Compiler.compiler_cxx
Type: behavior Stage: resolved
Components: Distutils, Distutils2 Versions: Python 3.1, Python 3.2, Python 2.7, 3rd party
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: eric.araujo Nosy List: alydar, dobesv, eric.araujo, furrykef, rpetrov, steve.dower, tarek, woodsplitter
Priority: low Keywords: easy

Created on 2003-10-29 04:27 by alydar, last changed 2021-02-03 18:30 by steve.dower. This issue is now closed.

Messages (8)
msg18790 - (view) Author: Allen Chan (alydar) Date: 2003-10-29 04:27
Using the following three files:

-- begin files -----
/* hello.cpp */
#include <stdio.h>
void hello()
{
    printf("hello world\n");
}
------------------
/* hello.i */
%module hello
extern void hello();
------------------
# setup.py
import distutils
from distutils.core import setup, Extension

setup(name = "Hello World",
        version = "1.0",
        ext_modules = [Extension("_hello",
            ["hello.i","hello.cpp"])])
-- end files -------


executing the command:
 "python setup.py build_ext -cmingw32 --swig-cpp -f"
creates the following output:

-- begin output --
running build_ext
building '_hello' extension
swigging hello.i to hello_wrap.cpp
...
[ snipped ]
...
cc -mno-cygwin -shared -s build\temp.win32-2.3
\Release\hello_wrap.o build\temp.w
in32-2.3\Release\hello.o build\temp.win32-2.3
\Release\_hello.def -LC:\p\Python23
\libs -LC:\p\Python23\PCBuild -lpython23 -o 
build\lib.win32-2.3\_hello.pyd
error: command 'cc' failed: No such file or directory
-- end output --

It appears that unixccompiler.py defaults compiler_cxx 
to use "cc" and then uses it for the linking, and 
cygwinccompiler.py does not override the compiler_cxx 
entry.  If the self.set_executable() call in the __init__*( 
function of the Mingw32Compiler class also sets 
compiler_cxx to use "g++", then the extension build will 
work.

msg18791 - (view) Author: David S. Rushby (woodsplitter) Date: 2004-02-11 23:18
Logged In: YES 
user_id=414645

I also encountered this bug while trying to build a C++
extension with no SWIG involved.
msg18792 - (view) Author: Kef Li Eric MARCVS X (furrykef) Date: 2004-08-20 17:26
Logged In: YES 
user_id=536129

ARGH! This bug is still in Python 2.3.4 and should have been
fixed A LONG TIME AGO! What am I supposed to do, have my
users fix their distutils by hand?

Sorry to be so gripy, but jeez. It tells you how to freaking
fix it...
msg18793 - (view) Author: Dobes V (dobesv) Date: 2007-05-22 17:18
Here's a workaround I used to fix the linker:

# Force g++ for linking
import distutils.sysconfig
old_customize_compiler = distutils.sysconfig.customize_compiler
def customize_compiler(compiler):
    old_customize_compiler(compiler)
    if compiler.compiler_type == 'mingw':
       compiler.set_executables(linker_so='g++ -mno-cygwin -shared')
distutils.sysconfig.customize_compiler = customize_compiler


You could also override the compiler, too.
msg121420 - (view) Author: √Čric Araujo (eric.araujo) * (Python committer) Date: 2010-11-18 02:18
The suggestion in the first message has to be turned into a patch.  A test has to be written too.
msg181837 - (view) Author: Roumen Petrov (rpetrov) * Date: 2013-02-10 18:45
In scope of issue12641 (Remove -mno-cygwin from distutils) I just publish a set of patches to modernize support for cygwin&mingw compilers.

My tests show that swig could be used successfully with patched mingw compiler. Test is based on patched official release 3.3.0 and my custom build of current master source with GNU windows compiler.
For protocol tested swig version is 2.0.9 and may be due syntax change swig module has to be described as :
-----
/* hello.i */
%module hello
%{
extern void hello(void);
%}

extern void hello(void);
-----

Distutils complain for --swig-cpp so command now is "python setup.py build_ext -cmingw32 --swig-cpp -f"
msg181838 - (view) Author: Roumen Petrov (rpetrov) * Date: 2013-02-10 18:46
Uhh "python setup.py build_ext -cmingw32 --swig-opts=-c++ -f"
msg386435 - (view) Author: Steve Dower (steve.dower) * (Python committer) Date: 2021-02-03 18:30
Distutils is now deprecated (see PEP 632) and all tagged issues are being closed. From now until removal, only release blocking issues will be considered for distutils.

If this issue does not relate to distutils, please remove the component and reopen it. If you believe it still requires a fix, most likely the issue should be re-reported at https://github.com/pypa/setuptools
History
Date User Action Args
2021-02-03 18:30:39steve.dowersetstatus: open -> closed

nosy: + steve.dower
messages: + msg386435

resolution: out of date
stage: test needed -> resolved
2013-02-10 18:46:06rpetrovsetmessages: + msg181838
2013-02-10 18:45:24rpetrovsetnosy: + rpetrov
messages: + msg181837
2010-11-18 02:18:31eric.araujosetassignee: tarek -> eric.araujo

components: + Distutils2
title: C++ extensions using SWIG and MinGW -> Bad value for Mingw32Compiler.compiler_cxx
nosy: + eric.araujo
versions: + 3rd party
messages: + msg121420
2010-08-18 22:59:20BreamoreBoysetversions: + Python 3.1, Python 2.7, Python 3.2, - Python 2.6
2009-02-14 12:27:56tareksetassignee: tarek
2009-02-14 12:22:18ajaksu2setnosy: + tarek
type: behavior
stage: test needed
2008-01-20 19:36:36christian.heimessetpriority: normal -> low
keywords: + easy
versions: + Python 2.6, - Python 2.3
2003-10-29 04:27:08alydarcreate