SWIG+Distutils - no harmony?
ruifernqq at gmail.com
ruifernqq at gmail.com
Sat Jul 7 06:23:05 EDT 2018
Em terça-feira, 15 de janeiro de 2002 21:26:05 UTC+1, Martin Bless escreveu:
> Getting courageous I try building 'example.pyd'
> from the SWIG 'Simple Example' using SWIG and the Distutils.
> Looks promising but doesn't succeed. I didn't
> modify 'example.c' and 'example.i'.
>
> Problems/questions:
>
> (1) Is 'setup.py' ok?
> (2) BEWARE: What's really shocking:
> After see (unsuccessful)
> python setup.py build -cmingw32
> the original 'example.c' is GONE AND AWAY -
> replaced by the wrapper.
> (3) What's going wrong?
>
> Martin
>
> Sources und logs following:
>
> >----------<>----------<>----------<
> # setup.py
> # mb: Is this ok?
> import distutils
> from distutils.core import setup, Extension
> #from distutils.extension import Extension
>
> setup(name = "Example 'Simple' from the SWIG examples",
> version = "2.2",
> ext_modules = [Extension("example", ["example.i"])])
>
> >----------<>----------<>----------<
> /* File : example.i */
> %module example
>
> extern int gcd(int x, int y);
> extern double Foo;
>
> >----------<>----------<>----------<
> /* File : example.c */
>
> /* A global variable */
> double Foo = 3.0;
>
> /* Compute the greatest common divisor of positive integers */
> int gcd(int x, int y) {
> int g;
> g = y;
> while (x > 0) {
> g = x;
> x = y % x;
> y = g;
> }
> return g;
> }
>
> >----------<>----------<>----------<
> C:\python
> Python 2.2 (#28, Dec 21 2001, 12:21:22) [MSC 32 bit (Intel)] on win32
> Type "help", "copyright", "credits" or "license" for more information.
> >>>
>
> >----------<>----------<>----------<
> swig -version
>
> SWIG Version 1.3.10u-20011211-2004
> Copyright (c) 1995-1998
> University of Utah and the Regents of the University of California
> Copyright (c) 1998-2001
> University of Chicago
>
> Compiled with CC
>
> >----------<>----------<>----------<
> >python setup.py build -cmingw32
>
> running build
> running build_ext
> building 'example' extension
> swigging example.i to example.c
> c:\pyext\swig\swig.exe -python -dnone
> -ISWIG -o example.c example.i
> c:\mingw\bin\gcc.exe -mno-cygwin -mdll
> -O -Wall -IC:\PYTHON22\include
> -c example.c -o build\temp.win32-2.2\Release\example.o
> writing build\temp.win32-2.2\Release\example.def
>
> c:\mingw\bin\gcc.exe -mno-cygwin -mdll -static
> -s build\temp.win32-2.2\Release\example.o
> build\temp.win32-2.2\Release\example.def
> -LC:\PYTHON22\libs -lpython22
> -o build\lib.win32-2.2\example.pyd
>
> swig: Warning. -dnone option deprecated.
>
> example.c: In function `SWIG_UnpackData':
> example.c:363: warning: `uu' might be used uninitialized in this
> function
> example.c: In function `SWIG_ConvertPtr':
> example.c:429: warning: suggest explicit braces to avoid ambiguous
> `else'
> example.c:432: warning: suggest explicit braces to avoid ambiguous
> `else'
> example.c:438: warning: suggest explicit braces to avoid ambiguous
> `else'
> example.c: At top level:
> example.c:154: warning: `SWIG_TypeQuery' defined but not used
> example.c:385: warning: `SWIG_ConvertPtr' defined but not used
> example.c:468: warning: `SWIG_ConvertPacked' defined but not used
> example.c:537: warning: `SWIG_MakeShadow' defined but not used
> build\temp.win32-2.2\Release\example.o(.text+0xbda):example.c:
> undefined reference to `gcd'
> build\temp.win32-2.2\Release\example.o(.text+0xc35):example.c:
> undefined reference to `Foo'
> build\temp.win32-2.2\Release\example.o(.text+0xc6b):example.c:
> undefined reference to `Foo'
> build\temp.win32-2.2\Release\example.o(.text+0xc71):example.c:
> undefined reference to `Foo'
> error: command 'gcc' failed with exit status 1
>
> >----------<>----------<>----------<
More information about the Python-list
mailing list