[Pythonmac-SIG] F2PY, F90, and Mac os x Tiger: linking problem

Louis Wicker Louis.Wicker at noaa.gov
Tue Dec 6 04:51:10 CET 2005


Back in April I upgraded to Tiger, and I should have known better.

I cannot get any f90/5 programs to link with f2py (except that I have  
not tried the g95/gfortran compilers).

This problem started when I "upgraded" to Tiger from 10.3.9.

I thought I would ask over to here to see if anyone has any ideas.

I get the same linking problem using the XLF, Absoft 9.2, and even  
the NAG compiler.
I can get g77 programs to compile and link correctly.

Here is the linking problem...it occurs at the end of the f2py  
process (see full output below).

/usr/bin/ld: /usr/lib/crt1.o has external relocation entries in non-
writable section (__TEXT,__text) for symbols:

This external relocation problem exists for all of the above named  
compilers.  I am using gcc 3.3.
My online research and my simple brain has figured out this is  
something to do with the gcc libs,
and the fact that something changed with 10.4.  The NAG README hints  
that something is weird with
Tiger and that they are temporarily supporting a "-unshared" flag -  
which I think allows me to link statically
somehow to a dynamic library.  I can successfully link using that  
flag, but the fortran module is dead when I import it
into python (it imports, but nothing happens when I try to access it).

This occurs with Python 2.3.5 and 2.4.1.  I cannot find anything  
anywhere on how to deal with this.

I have tried tricky other things, like compiling with f90 and linking  
with g77 or gcc, but I get
other types of errors.

Any thoughts would be appreciated, as this is irritating the hell out  
of me (for the third time this year).


======= Full output ====

f2py --fcompiler=ibm -c -m hello hello.f
      define_macros = [('NUMERIC_VERSION', '"\\"24.0b2\\""')]
      include_dirs = ['/System/Library/Frameworks/Python.framework/

running build
running config_fc
running build_src
building extension "hello" sources
f2py:> /tmp/tmpEAl_LK/src/hellomodule.c
creating /tmp/tmpEAl_LK
creating /tmp/tmpEAl_LK/src
Reading fortran codes...
          Reading file 'hello.f'
          Block: hello
                          Block: foo
Post-processing (stage 2)...
Building modules...
          Building module "hello"...
                  Constructing wrapper function "foo"...
          Wrote C/API module "hello" to file "/tmp/tmpEAl_LK/src/
    adding '/tmp/tmpEAl_LK/src/fortranobject.c' to sources.
    adding '/tmp/tmpEAl_LK/src' to include_dirs.
copying /System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/f2py2e/src/fortranobject.c -> /tmp/tmpEAl_LK/src
copying /System/Library/Frameworks/Python.framework/Versions/2.3/lib/
python2.3/site-packages/f2py2e/src/fortranobject.h -> /tmp/tmpEAl_LK/src
running build_ext
customize UnixCCompiler
customize UnixCCompiler using build_ext
customize IbmFCompiler
customize IbmFCompiler using build_ext
building 'hello' extension
compiling C sources
gcc options: '-fno-strict-aliasing -Wno-long-double -no-cpp-precomp -
mno-fused-madd -fno-common -dynamic -DNDEBUG -g -O3 -Wall -Wstrict-
creating /tmp/tmpEAl_LK/tmp
creating /tmp/tmpEAl_LK/tmp/tmpEAl_LK
creating /tmp/tmpEAl_LK/tmp/tmpEAl_LK/src
compile options: '-I/System/Library/Frameworks/Python.framework/
Versions/2.3/include/python2.3 -I/tmp/tmpEAl_LK/src -I/System/Library/
Frameworks/Python.framework/Versions/2.3/include/python2.3 -c'
gcc: /tmp/tmpEAl_LK/src/fortranobject.c
/tmp/tmpEAl_LK/src/fortranobject.c: In function `fortran_doc':
/tmp/tmpEAl_LK/src/fortranobject.c:123: warning: int format, long
unsigned int arg (arg 3)
gcc: /tmp/tmpEAl_LK/src/hellomodule.c
compiling Fortran sources
xlf(f77) options: '-qextname -O5'
xlf90(f90) options: '-qextname -O5'
xlf90(fix) options: '-qfixed -qextname -O5'
compile options: '-I/System/Library/Frameworks/Python.framework/
Versions/2.3/include/python2.3 -I/tmp/tmpEAl_LK/src -I/System/Library/
Frameworks/Python.framework/Versions/2.3/include/python2.3 -c'
xlf:f77: hello.f
** foo   === End of Compilation 1 ===
1501-510  Compilation successful for file hello.f.
xlf95 -Wl,-bundle,-flat_namespace,-undefined,suppress /tmp/tmpEAl_LK/
tmp/tmpEAl_LK/src/hellomodule.o /tmp/tmpEAl_LK/tmp/tmpEAl_LK/src/
fortranobject.o /tmp/tmpEAl_LK/hello.o -o ./hello.so
/usr/bin/ld: /usr/lib/gcrt1.o has external relocation entries in non-
writable section (__TEXT,__text) for symbols:
/usr/bin/ld: /usr/lib/gcrt1.o has external relocation entries in non-
writable section (__TEXT,__text) for symbols:
error: Command "xlf95 -Wl,-bundle,-flat_namespace,-
undefined,suppress /tmp/tmpEAl_LK/tmp/tmpEAl_LK/src/hellomodule.o /
tmp/tmpEAl_LK/tmp/tmpEAl_LK/src/fortranobject.o /tmp/tmpEAl_LK/
hello.o -o ./hello.so" failed with exit status 1
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/pythonmac-sig/attachments/20051205/2bf2c67d/attachment.html

More information about the Pythonmac-SIG mailing list