2014-06-11 1 views
3

지난 몇 날 동안 나는 Fortran 코드를 컴파일 할 수 없었습니다. (이 코드의 작성자가 아니며, author's web page에서 다운로드했습니다.) 오픈 소스). 주 프로그램은 multitaper.f95라고하며, plot 및 spectra라는 모듈과 mwlib.a 및 gplot.a라는 라이브러리를 사용합니다. 나는 multitaper.f95, mwlib.a, gplot.a, plot.mod 및 spectra.mod를 모두 동일한 디렉토리에 있습니다. 플롯 및 스펙트럼 모듈은 gplot.f90 및 mtspec.f95에서 각각 생성되며 다른 모든 것과 동일한 디렉토리에 있습니다. 그러나 다음 명령은 오류 메시지를 생성합니다 : gplot.f90의'gplot_'에 대한 Fortran 알 수없는 참조

gfortran multitaper.f95 mtspec.f95 gplot.f90 -o multitaper -L gplot.a mwlib.a 
/tmp/ccBJzwYI.o: In function `MAIN__': 
multitaper.f95:(.text+0x1111): undefined reference to `gplot_' 
multitaper.f95:(.text+0x11af): undefined reference to `gplot_' 
multitaper.f95:(.text+0x1246): undefined reference to `gplot_' 
collect2: error: ld returned 1 exit status 

내용은

module plot 

! 
! Interface to allow for x or y to be a matrix, and plot each vector 
! of y against x. The matrix is given by horizontal vectors, y(:,1) is 
! the first vector. 
! April 22 2005 
!  Allowing to also use real(4) and real(8) units. 
! 

! 
! Interface 
!   dvv vector vs vector 
!  dvm vector vs matrix 
!  dmm matrix vs matrix 
!  rvv real(4) vector vs vector 
!  rvm real(4) vector vs matrix 
!  rmm real(4) matrix vs matrix 
! 

interface gnuplot 
    module procedure gnuplot_dvv, gnuplot_dvm, gnuplot_dmm,    & 
        gnuplot_rvv, gnuplot_rvm, gnuplot_rmm,    & 
        gnuplot_rv, gnuplot_rm  
end interface gnuplot 

! The subroutines 

contains 

!The NEW GNUPlot subroutines 

include 'gnuplot.f90' 

end module plot 

!====================================================================== 

Gnuplot.f90의 코드 3700 개 라인을 가지고, 그래서 내가 여기에 게시하지 않습니다. 나는 Fortran을 처음 사용하기 때문에 바보 같은 짓을하고 있다면 미리 사과드립니다. 그러나, 나는 해결책을 찾고있는 며칠 동안 인터넷을 빗질 해왔다. 그러나 나는 많이 나타나지 않았다. 이 (Fortran compilation error - undefined reference)을 찾았지만 multitaper.f95에는 스펙트럼과 플롯 모두에 대한 use 문이 있으며 gplot과 gnuplot.f90의 서브 루틴은 private이 아닙니다. https://gcc.gnu.org/wiki/GFortranGettingStartedhttp://www.oceanographers.net/forums/showthread.php?378-How-to-make-a-FORTRAN-library에 따르면, 나의 지식은 최선을 다해 나의 터미널 주문을 받아야한다. 확실하게, 나는 계속 나아가서 gplot.f90과 mtspec.f95를 따로 컴파일 해보고 객체 파일을 gfortran 명령에 제공하려고 시도했다. 그러나 이것은 아무것도 변경하지 않았다. 나는 또한 버전 충돌을 가져올 수있는 것이 없기 때문에 gplot.f90과 gnuplot.f90의 파일 확장자를 f95로 변경하려고 시도했지만 다시 한번 동일한 오류 메시지를 생성했습니다. 또한, -L 명령 다음에 디렉토리에 대한 전체 경로를 포함 시키려고 시도했지만, 동일한 오류 메시지가 나타납니다.

Makefile이 더 이상 작동하지 않으며 필자는 그 파일에 대해 많이 알지 못하고 어떻게 작동하는지 알지 못합니다. make 명령을 실행할 때 수동으로 컴파일하려고 할 때 다음 오류가 발생합니다. 다음과 같이 메이크 파일의 내용은 다음과 같습니다

# Location of files 

DIR = /N/u/rccaton/Quarry/EarthHum/mtspec/program 
LIB = /N/u/rccaton/Quarry/EarthHum/mtspec/program 
#LIB2 = 

# Objects and Libraries 

OBJS = $(LIB)/mwlib.a \ 
     $(LIB)/gplot.a \ 
#  /Applications/Absoft/lib/libU77.a 


# Module locations 

MODS = $(LIB) 
MODS2 = $(LIB) 

# Compiler 
#FC =  g95 
#FC =  f95 
FC = gfortran 

# Compiler flags 
# none 
FLAGS = 
# debug 
#FFLAGS = -g 

# Module flag 

# Sun Compiler 
#MFLAG = -M 
# Nag Compiler 
#MFLAG = -i 
MFLAG = -I 
# Absoft Compiler 
#MFLAG = -p 
# g95 compiler 
#MFLAG = -I 

MODULE = $(MFLAG)$(MODS) # $(MFLAG)$(MODS2) 

# Compile 

all : multitaper 

%:  %.f95 $(OBJS) 
    $(FC) $(FFLAGS) $(MODULE) $< $(OBJS) -o [email protected] 


# Clean 

clean : 
    rm multitaper 

그것을 내가 메이크 또는 수동 명령으로 컴파일 결국 여부 나에게 차이로 만드는 하루의 끝에서, 난 그냥 실행되도록해야합니다. 이 정보가 길면 죄송 합니다만 가능한 한 많은 관련 정보를 제공하고 싶습니다. 제공 할 수있는 도움에 감사드립니다.

+0

아마도 작성자에게 물어보십시오. 서브 루틴이나 함수 "gplot"이 "gplot.f90"에 나타 납니까? 밑줄이 있습니까? 그렇지 않다면 저자의 프로그램은 밑줄을 사용합니까? 불일치가 있으면 코드를 편집하고 밑줄을 제거하십시오. –

답변

2
내가 gfortran 플래그를 검색 gplot.a

nm gplot.a | grep -i "gplot" 

에서 내 보낸 된 기호를 발견하고 그에 따라 컴파일러에게 플래그를 변경 제안

: 저자에게 문의

-fno-underscoring 
-fsecond-underscore 
-fcase-* 

를 도움이되지 않는 경우 올바른 MakeFile을 제공합니다.

관련 문제