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

Created on 2003-10-29 04:27 by alydar, last changed 2010-11-18 02:18 by eric.araujo.

Messages (5)
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.
History
Date User Action Args
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