How to solve gfortran compilation and linking error?

0

I have trying to compile a collection of old fortran and C codes with gfortran. They compile fine on a linux workstation but this fails in a Mac. Any idea on how to solve this ? The Makefile in the Linux version has one extra flag in CFLAGS and FFLAGS -mcmodel=large that I removed following some advice.

This is the error at the final linking line.

gfortran -fopenmp -O3 -m64 lsmrDataModule.o lsmrModule.o delsph.o gaussian.o CalSurfG2.o main2.o aprod.o cluster1.o covar.o datum.o delaz.o delaz2.o direct1.o dist.o exist.o freeunit.o ifindi.o indexxi.o juliam.o matmult1.o matmult2.o matmult3.o mdian1.o normlz.o ran.o redist.o resstat_FDD.o scopy.o sdc2.o setorg.o snrm2.o sort.o sorti.o sscal.o svd.o tiddid.o trialsrc_FDD_shot.o trimlen.o vmodel.o RaySPDR2new.o getinpSPDR.o getdata_SPDR.o dtres_FDD_lm5.o weighting_FDD.o lsfitHFDD_lsqr_lm5.o get_dims.o add_sta.o find_id2.o surfdisp96.o atoangle_.o atoangle.o datetime_.o hypot_.o rpad_.o sscanf3_.o transform_r_gfortran_double.o   -o tomoJointBS
final section layout:
    __TEXT/__text addr=0x1000014A0, size=0x0008F7D1, fileOffset=0x000014A0, type=1
    __TEXT/__text_startup addr=0x100090C80, size=0x00000026, fileOffset=0x00090C80, type=1
    __TEXT/__stubs addr=0x100090CA6, size=0x0000018C, fileOffset=0x00090CA6, type=28
    __TEXT/__stub_helper addr=0x100090E34, size=0x000002A4, fileOffset=0x00090E34, type=32
    __TEXT/__cstring addr=0x1000910D8, size=0x000130B9, fileOffset=0x000910D8, type=13
    __TEXT/__const addr=0x1000A41A0, size=0x00004C6C, fileOffset=0x000A41A0, type=0
    __TEXT/__eh_frame addr=0x1000A8E10, size=0x000051E0, fileOffset=0x000A8E10, type=19
    __DATA/__got addr=0x1000AE000, size=0x00000028, fileOffset=0x000AE000, type=29
    __DATA/__nl_symbol_ptr addr=0x1000AE028, size=0x00000010, fileOffset=0x000AE028, type=29
    __DATA/__la_symbol_ptr addr=0x1000AE038, size=0x00000210, fileOffset=0x000AE038, type=27
    __DATA/__const addr=0x1000AE248, size=0x00000010, fileOffset=0x000AE248, type=0
    __DATA/__data addr=0x1000AE260, size=0x00000030, fileOffset=0x000AE260, type=0
    __DATA/__pu_bss2 addr=0x1000AE290, size=0x000000A8, fileOffset=0x00000000, type=25
    __DATA/__pu_bss5 addr=0x1000AE340, size=0x000004C0, fileOffset=0x00000000, type=25
    __DATA/__bss5 addr=0x1000AE800, size=0x00229680, fileOffset=0x00000000, type=25
    __DATA/__pu_bss3 addr=0x1002D7E80, size=0x00000028, fileOffset=0x00000000, type=25
    __DATA/__common addr=0x1002D7EC0, size=0x000000A0, fileOffset=0x00000000, type=25
    __DATA/__bss3 addr=0x1002D7F60, size=0x00000010, fileOffset=0x00000000, type=25
    __DATA/__bss2 addr=0x1002D7F70, size=0x00000004, fileOffset=0x00000000, type=25
    __DATA/__huge addr=0x1002D7F80, size=0x3FA6069F4, fileOffset=0x00000000, type=25
ld: unexpected bindingNone in '_MAIN__' from main2.o for architecture x86_64
collect2: error: ld returned 1 exit status
make: *** [tomoJointBS] Error 1

This is the Makefile.

CMD = tomoJointBS
CC  = gcc
FC  = gfortran
SRCS    = main2.f\
      aprod.f cluster1.f covar.f datum.f \
      delaz.f delaz2.f direct1.f dist.f exist.f \
      freeunit.f ifindi.f \
      indexxi.f juliam.f  \
      matmult1.f matmult2.f matmult3.f mdian1.f \
      normlz.f ran.f redist.f \
      resstat_FDD.f scopy.f sdc2.f setorg.f \
      snrm2.f sort.f sorti.f sscal.f \
      svd.f tiddid.f trialsrc_FDD_shot.f trimlen.f \
      vmodel.f RaySPDR2new.f  \
          getinpSPDR.f getdata_SPDR.f \
          dtres_FDD_lm5.f weighting_FDD.f lsfitHFDD_lsqr_lm5.f \
      get_dims.f add_sta.f find_id2.f \
      surfdisp96.f 
CSRCS   = atoangle_.c atoangle.c datetime_.c hypot_.c rpad_.c \
          sscanf3_.c transform_r_gfortran_double.c
F90SRCS = lsmrDataModule.f90 \
          lsmrModule.f90 delsph.f90 gaussian.f90
OBJS    = $(F90SRCS:%.f90=%.o) CalSurfG2.o $(SRCS:%.f=%.o) $(CSRCS:%.c=%.o) 
INCLDIR = ./include

CFLAGS = -O3 -I$(INCLDIR) -m64
FFLAGS  = -O3 -I$(INCLDIR) -ffixed-line-length-none -ffloat-store -W  -m64 -fbounds-check
LDFLAGS         = -O3 -m64

all: $(CMD) 

$(CMD): $(OBJS)
    $(FC) -fopenmp $(LDFLAGS) $(OBJS) $(LIBS) -o $@
%.o: %.f90
    $(FC) $(FFLAGS) -c $(@F:.o=.f90) -o $@
CalSurfG2.o:CalSurfGnew2.f90                                                 
        $(FC) -fopenmp $(FFLAGS) -c $< -o $@
%.o: %.f
    $(FC) $(FFLAGS) -c $(@F:.o=.f) -o $@
fortran
gfortran
asked on Stack Overflow Sep 24, 2019 by Guddu

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0