[C++-SIG] Re: C++ extension module crashes on Solaris

Steve Harris sharris at primus.com
Fri May 19 22:22:36 CEST 2000


"Lyle Johnson" <jlj at cfdrc.com> writes:

[...]

> I use these flags to compile the individual files:
> 
> 	g++ -fPIC -c file1.cpp
> 	g++ -fPIC -c file2.cpp
> 
> and then for the link step:
> 
> 	g++ -Wl,-E -shared -o seh_test.so file1.o file2.o ...
> 
> I noticed in particular that you are not using the "-fPIC" flag for
> the compile step. I know that this is REQUIRED on most platforms for
> this to work properly, so it might be the missing piece of the
> puzzle in your case.

I didn't recompile Python yet, but I did rebuild my extension module
and got a similar, but different result:


$ make
g++ -fPIC -I../Include -g -O2 \
  -I/users/sharris/usr/local/include/python1.5 -DHAVE_CONFIG_H \
  -c ./pod.cc
g++ -fPIC -I../Include -g -O2 \
  -I/users/sharris/usr/local/include/python1.5 -DHAVE_CONFIG_H \
  -c ./pypod.cc
g++ -fPIC -I../Include -g -O2 \
  -I/users/sharris/usr/local/include/python1.5 -DHAVE_CONFIG_H \
  -c ./seh_test.cc
g++ -fPIC -I../Include -g -O2 \
  -I/users/sharris/usr/local/include/python1.5 -DHAVE_CONFIG_H \
  -c ./../Src/cxx_extensions.cxx
gcc -I../Include -g -O2 \
  -I/users/sharris/usr/local/include/python1.5 -DHAVE_CONFIG_H \
  -c ./../Src/cxxextensions.c
g++ -fPIC -I../Include -g -O2 \
  -I/users/sharris/usr/local/include/python1.5 -DHAVE_CONFIG_H \
  -c ./../Src/cxxsupport.cxx
g++ -shared -Wl,-E  \
  pod.o pypod.o seh_test.o \
  cxx_extensions.o cxxextensions.o cxxsupport.o \
  -o seh_test.so

$ cp seh_test.so ~/usr/local/lib/python1.5/
$ python
Python 1.5.2 (#1, May 19 2000, 09:34:45)  [GCC 2.95.2 19991024 (release)] on sunos5
Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
>>> import seh_test
Traceback (innermost last):
  File "<stdin>", line 1, in ?
ImportError: ld.so.1: python: fatal: relocation error: file ./seh_test.so: symbol PyExc_RuntimeError: referenced symbol not found
>>>


Note that this time, it's the symbol PyExc_RuntimeError that's causing
the problem.

Does it matter that the gcc line above (for ../Src/cxxextensions.c)
doesn't have the 'fPIC' option on it?

-- 
Steven E. Harris
Primus Knowledge Solutions, Inc.
http://www.primus.com




More information about the Cplusplus-sig mailing list