SWIG compilation woes.

Lyle Johnson ljohnson at resgen.com
Mon Nov 13 18:25:30 CET 2000


Steve,

I went to google (http://www.google.com) and typed in the search keywords
"swig relocations remain against" and it went straight to a pair of pages
which will probably solve your problem:

    http://www.cs.uchicago.edu/pipermail/swig/2000-February/001069.html
    http://www.cs.uchicago.edu/pipermail/swig/2000-February/001074.html

To summarize, the fix seems to be to compile the individual source files
with compiler flags "-fPIC" and "-shared" and then link with linker flag
"-shared".

Hope this helps,

Lyle

"Steve Juranich" <sjuranic at condor.ee.washington.edu> wrote in message
news:Pine.SOL.3.96.1001110095516.13923C-100000 at condor.ee.washington.edu...
> I'm confronted with the task of setting up SWIG myself.  We have a very
> non-standard (degrees of non-standardness?? hmm...) distribution of tcl,
> perl, and python.  Obviously, my first priority is getting the python
tools
> working.
>
> When I run make testbuild, none of the statically linked modules work
(which
> is fine with me) and dynamic modules will work for tcl and Python if the
> modules were written in C.  However, when it gets to testing the C++ code,
> nothing works at all.  For the Python modules in C++, I get a bunch of
> linker errors.  Here's was Test/Build/python_dynamic.c++.output says:
>
>
> make[3]: Entering directory
`/atm/homes/raven0/sjuranic/tmp/SWIG1.1p5/Tests/Build'
> make -f ../../Makefile.template SRCS='' SWIG='../../swig' \
> SWIGOPT='-I../../swig_lib' \
> TARGET='shapes' INTERFACE='shapes.i ' python_cpp
> make[4]: Entering directory
`/atm/homes/raven0/sjuranic/tmp/SWIG1.1p5/Tests/Build'
> ../../swig -c++ -python -I../../swig_lib shapes.i
> Generating wrappers for Python
> /g/rcs/sw/bin/g++ -c


shapes_wrap.c    -DHAVE_CONFIG_H -I/g/rcs/sw/pkgs/python-1.6/include/python1
.6
> /g/rcs/sw/bin/g++ -shared   shapes_wrap.o    -o shapesmodule.so
> Text relocation remains                 referenced
>     against symbol     offset in file
> <unknown>                           0x24      shapes_wrap.o
> ... (I get about 500 of these) ...
> Py_InitModule4                      0x1f8c    shapes_wrap.o
> ld: fatal: relocations remain against allocatable but non-writable
sections
> collect2: ld returned 1 exit status
> make[4]: *** [python_cpp] Error 1
> make[4]: Leaving directory
`/atm/homes/raven0/sjuranic/tmp/SWIG1.1p5/Tests/Build'
> make[3]: *** [python_dynamic] Error 2
> make[3]: Leaving directory
`/atm/homes/raven0/sjuranic/tmp/SWIG1.1p5/Tests/Build'
>
> Can anybody tell me what is going on and how to fix it?  I'm fairly
certain
> that SWIG is (for the most part) configured correctly because it will
> compile Python modules written in C.  But given the OO-ness of Python, I
> will obviously want to be writing some C++ code as well.
>
> Thanks for the help.
>
> ----------------------------------------------------------------------
> Stephen W. Juranich                         sjuranic at ee.washington.edu
> Electrical Engineering         http://students.washington.edu/sjuranic
> University of Washington             http://rcs.ee.washington.edu/ssli
>
>





More information about the Python-list mailing list