[Distutils] errors compiling c++ extensions with swig on windows

Christian K. ckkart at hoc.net
Fri Sep 7 03:15:54 CEST 2007


Hi,

using the following setup file to build a extension  from c++ source on
windows/mingw with swig 1.3.31,

import distutils
from distutils.core import setup, Extension

ext = Extension("_libpyorigin",
                ["libpyorigin.i","OPJFile.cpp"],
                extra_compile_args = ['-w'])

setup(name = "libpyorigin",
      version = "0.1",
      options={'build_ext':{'swig_opts':'-c++'}},
      ext_modules = [ext])

I get the following error:

$ python setup.py build_ext --compiler=mingw32
running build_ext
building '_libpyorigin' extension
swigging libpyorigin.i to libpyorigin_wrap.cpp
C:\msys\1.0\local\bin\swig.exe -python -c++ -o libpyorigin_wrap.cpp libpyorigin.i
c:\mingw\bin\gcc.exe -mno-cygwin -mdll -O -Wall -Ic:\Python25\include
-Ic:\Python25\PC -c libpyorigin_wrap.cpp -o
build\temp.win32-2.5\Release\libpyorigin_wrap.o -w
writing build\temp.win32-2.5\Release\_libpyorigin.def
c:\mingw\bin\g++.exe -mno-cygwin -mdll -static --entry _DllMain at 12 --output-lib
build\temp.win32-2.5\Release\lib_libpyorigin.a --def
build\temp.win32-2.5\Release\_libpyorigin.def -s
build\temp.win32-2.5\Release\libpyorigin_wrap.o
build\temp.win32-2.5\Release\opjfile.o -Lc:\Python25\libs -Lc:\Python25\PCBuild
-lpython25 -lmsvcr71 -o build\lib.win32-2.5\_libpyorigin.pyd
g++: build\temp.win32-2.5\Release\lib_libpyorigin.a: No such file or directory
error: command 'g++' failed with exit status 1

What is distutils trying to do with that lib_libpyorigin.a? I could not find the
meaning of --output-lib but I suspect g++ is trying to link with that lib but it
 was meant to build it, right? Is this a bug in distutils or did I do seomething
wrong?

The same works perfectly on linux, btw.

Thanks, Christian




More information about the Distutils-SIG mailing list