6

I'm trying to compile some source code from a makefile, but its not working. The error I get is

gfortran-9 -o sams43 sams43.o mvnorm.o isml_wrapper.o
/usr/bin/ld: sams43.o: relocation R_X86_64_32 against '.rodata' can not be used when making a PIE object; recompile with -fPIE
collect2: error: ld returned 1 exit status
make: *** [makefile:7: sams43] Error 1

Here's my makefile:

FC=gfortran-9
FCFLAGS= -g

all: sams43 normal_dataset

sams43: sams43.o mvnorm.o imsl_wrapper.o 
    ${FC} -o sams43 sams43.o mvnorm.o imsl_wrapper.o

imsl_wrapper.o: imsl_wrapper.f90
    ${FC} ${FCFLAGS} -c imsl_wrapper.f90

sams43.o: sams43.f90
    ${FC} ${FCFLAGS} -c sams43.f90

mvnorm.o: mvnorm.f90
    ${FC} ${FCFLAGS} -c mvnorm.f90

normal_dataset: normal_dataset.o mvnorm.o
    ${FC} -o normal_dataset normal_dataset.o mvnorm.o

normal_dataset.o: normal_dataset.f90
    ${FC} ${FCFLAGS} -c normal_dataset.f90

clean:
#   rm *.o sams43 normal_dataset

I am using Ubuntu 20.04. My collaborator is able to compile the make file on an older version of ubuntu with no problems. The only difference between her make file and mine is that I changed 'FC=gfortran' to 'FC=gfortran-9'. This is because gfortran no longer works on my version of Ubuntu, so I am using gfortran-9 as my compiler instead.

From reading other posts on here, it seems like it could be an issue with the flags that I'm using (i.e. the codes might have changed between the two fortran versions) but I've not been able to find any information on what flag to put in instead.

I am very new to programming, and any help would be appreciated!

LouiseC
  • 61
  • 1
  • 1
  • 2
  • 3
    Have you tried to "recompile with -fPIE", adding to the compiler options? – francescalus Oct 07 '20 at 15:55
  • 1
    Thanks, as a completely new coder, this could work but I don't know where to add this statement. Would I add it into my makefile? Does it matter where I put it in the makefile? – LouiseC Oct 07 '20 at 16:07
  • You can add to the `FCFLAGS = ` line (for some of the steps), but would also be needed for `${FC} -fPIE` under the `sams43:` line. – francescalus Oct 07 '20 at 16:16
  • Usually you would put the `${FCFLAGS}` onto the link line as well as the compile lines. – MadScientist Oct 07 '20 at 16:21

0 Answers0