1

I'm trying to interface CUTEst with python using ugly. I tried to use f2py like so:

f2py -c -m ugly \
 /home/gabriel/Documentos/ugly/src/gen77/gen77_main.f \
 /home/gabriel/Documentos/ugly/src/gen77/gen77.f \
 ELFUN.f GROUP.f RANGE.f \
 -L/home/gabriel/Documentos/ugly/objects/pc64.lnx.gfo/double \
 -lcutest

where libcutes.a is in /home/gabriel/Documentos/ugly/objects/pc64.lnx.gfo/double. f2py did not generate the file ugly.os and gave this message:

/usr/bin/ld: /home/gabriel/Documentos/ugly/objects/pc64.lnx.gfo/double/libcutest.a(usetup.o): no se puede usar la reubicación R_X86_64_32S contra `.rodata.str1.1' cuando se hace un objeto compartido; recompile con -fPIC

On the other hand if I compile with gfortran it works.

dg99
  • 5,456
  • 3
  • 37
  • 49

1 Answers1

0

To use code in an object file from Python, the object file must be compiled to use position independent code so that the linker can include it as a part of a shared object. The error is saying that the library .rodata.str1.1 wasn't compiled to use position independent code, so it can't be included in a shared object. You need to recompile the library you are linking against and pass the additional flag -fPIC to gcc/gfortran when you compile it.

IanH
  • 10,250
  • 1
  • 28
  • 32