-1

I want to run a FORTRAN subroutine from R. I read that, I need a shared object (.so file) to run the subroutine. For creating the shared object I successfully compiled the FORTRAN subroutine. But when creating shared object it gave the following error

/usr/bin/ld: temain.o: relocation R_X86_64_32 against `.rodata' can not be 
used when making a shared object; 
recompile with -fPIC
temain.o: could not read symbols: Bad value
collect2: error: ld returned 1 exit status

the command given was gfortran -shared -o temain.so *.o

What do I do? Thanks in advance

1 Answers1

0

You need -fPIC as the error message says.

See the Writing R Extensions manual and use R CMD COMPILE myfile.f.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725