Bugs item #832159, was opened at 2003-10-29 04:27 Message generated for change (Comment added) made by dobesv You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=832159&group_id=5470
Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: Distutils Group: Python 2.3 Status: Open Resolution: None Priority: 5 Private: No Submitted By: Allen Chan (alydar) Assigned to: Nobody/Anonymous (nobody) Summary: C++ extensions using SWIG and MinGW Initial Comment: 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. ---------------------------------------------------------------------- Comment By: Dobes V (dobesv) Date: 2007-05-22 17:18 Message: Logged In: YES user_id=400635 Originator: NO 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. ---------------------------------------------------------------------- Comment By: Kef X-Schecter (furrykef) Date: 2004-08-20 17:26 Message: 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... ---------------------------------------------------------------------- Comment By: David S. Rushby (woodsplitter) Date: 2004-02-11 23:18 Message: Logged In: YES user_id=414645 I also encountered this bug while trying to build a C++ extension with no SWIG involved. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=832159&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com