Fortran unable to call external library -
i trying utilize external library called "decomp_2d" fortran program. have environment variable declared "decomp2d" points directory "decomp_2d" located. directory has next structure:
[k00603@fe01p03 2decomp_fft]$ls doc examples include lib makefile readme src [k00603@fe01p03 2decomp_fft]$ls lib/ lib2decomp_fft.a makefile [k00603@fe01p03 2decomp_fft]$ls include/ decomp_2d_fft.mod decomp_2d_io.mod decomp_2d.mod glassman.mod
in directory trying phone call programme uses subroutines of library. when doing this, getting compile time error. attaching minimal fortran code using , makefile using compile. fujitsu machine , have there own fortran compiler using compile:
the program:
programme sora_v71 ! utilize external library utilize decomp_2d integer n phone call decomp_2d_init(n,n,n,n,n) stop end
makefile:
# lines included using 2decomp libraries inc_2decomp = -i$(decomp2d)/include/ l2decomp = -l$(decomp2d)/lib/ -l2decomp_fft ## ------------------------------------------------------ rm = rm srcdir = . libdir = . bin = binary objs = main.o ## ------------------------------------------------------- mpifrtpx=$(shell mpifrtpx) fc=$(mpifrtpx) fflags = $(f90flag) $(inc_2decomp) lflags = $(f90flag) -l$(libdir) $(l2decomp) ## ------------------------------------------------------- all: $(bin) $(bin): $(objs) @echo linking $(bin) ..... $(fc) $(lflags) -o $@ $(objs) .f.o: @echo compiling $*.f $(fc) $(fflags) -c $(srcdir)/$*.f clean: @echo 'cleaning .....' $(rm) -f core *.o *~ *.l *.o $(bin) $(size_file)
when typing "make" getting next error:
[k00603@fe01p04 test]$make compiling main.f /opt/fjsvtclang/gm-1.2.0-11/bin/mpifrtpx -i/home/hp120242/k00603/2decomp_fft//include/ -c ./main.f linking binary ..... /opt/fjsvtclang/gm-1.2.0-11/bin/mpifrtpx -l. -l/home/hp120242/k00603/2decomp_fft//lib/ -l2decomp_fft -o binary main.o main.o: in function `main__': main.f:(.text+0x4c): undefined reference `decomp_2d.decomp_2d_init_' main.o:(.data+0x0): undefined reference `decomp_2d.decomp_2d_init_' make: *** [binary] error 1
any ideas?
with linkers order of libraries in linking command matters. have come after object files reference them. seek switch $(lflags)
, $(objs)
in link command.
fortran external fujitsu
No comments:
Post a Comment