문제

모두 인사하고

G ++를 사용하여 컴파일하려고 시도하고 MakeFile의 일부 Fortran 소스 코드에 대한 표준 F90 (또는 F77 균일) 라이브러리를 연결해야합니다. 어디서나 이름을 찾을 수 없습니다.

Makerfile :

products: SlowDynamic.exe

SlowDynamic.exe: main.o SA.o mersenne.o CFE.o BCs.o EMatrix.o Numbering.o KMatrix.o Solve.o MA_57.o blas.o MA_57_Depend.o Metis.o
    g++ -L/usr/sfw/lib -R/usr/sfw/lib -lgcc_s -lstdc++ -o SlowDynamic.exe main.o \
        SA.o mersenne.o CFE.o MA_57.o blas.o MA_57_Depend.o Metis.o\
        BCs.o EMatrix.o Numbering.o KMatrix.o Solve.o

main.o: main.cpp
    g++ -c -o main.o main.cpp

SA.o: SA.cpp
    g++ -c -o SA.o SA.cpp

mersenne.o: mersenne.cpp
    g++ -c -o mersenne.o mersenne.cpp

CFE.o: CFE.c
    gcc -c -o CFE.o CFE.c

MA_57.o: MA_57.f
    f77 -c -o MA_57.o MA_57.f

blas.o: blas.f
    f77 -c -o blas.o blas.f

MA_57_Depend.o: MA_57_Depend.f
    f77 -c -o MA_57_Depend.o MA_57_Depend.f

Metis.o: Metis.f
    f77 -c -o Metis.o Metis.f

BCs.o: BCs.c
    gcc -c -o BCs.o BCs.c

EMatrix.o: EMatrix.c
    gcc -c -o EMatrix.o EMatrix.c

Numbering.o: Numbering.c
    gcc -c -o Numbering.o Numbering.c

KMatrix.o: KMatrix.c
    gcc -c -o KMatrix.o KMatrix.c

Solve.o : Solve.c
    gcc -c -o Solve.o Solve.c

clean: 
    rm *.o Main.exe *.gpi

컴파일러:

birch $ make
mksh: Warning: newline is not last character in file Makefile
Current working directory /u/f/osv20/Y4-UNIX/complete
g++ -L/usr/sfw/lib -R/usr/sfw/lib -lgcc_s -o SlowDynamic.exe main.o \
        SA.o mersenne.o CFE.o MA_57.o blas.o MA_57_Depend.o Metis.o\
        BCs.o EMatrix.o Numbering.o KMatrix.o Solve.o
Undefined                       first referenced
 symbol                             in file
__f90_sfw_i4                        MA_57.o
__f90_sfw_ch                        MA_57.o
__f90_sfw_r4                        MA_57.o
__f90_ifw_ch                        MA_57.o
__f90_ifw_r4                        MA_57.o
__nintf                             MA_57.o
__s_cmp                             blas.o
__r_sign                            MA_57_Depend.o
__f90_sifw                          MA_57.o
__f90_ssfw                          MA_57.o
__f90_stop                          blas.o
__f90_esfw                          MA_57.o
__f90_eifw                          MA_57.o
ld: fatal: Symbol referencing errors. No output written to SlowDynamic.exe
collect2: ld returned 1 exit status
*** Error code 1
make: Fatal error: Command failed for target `SlowDynamic.exe'

'f77 -v hello.f'실행 결과

amos $ f77 -v hello.f
NOTICE: Invoking /usr/bin/f90 -f77 -ftrap=%none -v hello.f
###     command line files and options (expanded):
### -f77=%all -ftrap=%none -v hello.f -lf77compat
### f90: Note: NLSPATH = /opt/SUNWspro/prod/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/SUNWspro/prod/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
/opt/SUNWspro/prod/bin/f90comp -y-o -yhello.o -ev -y-ftrap=%none -m3 -dq -y-fbe -y/opt/SUNWspro/prod/bin/fbe -y-xarch=generic -y-s -H "/opt/SUNWspro/prod/bin/f90 -f77 -ftrap=%none -v " -y-xcache=generic -xcache=generic -I/opt/SUNWspro/prod/include/f95/v8 -p/opt/SUNWspro/prod/lib/modules -y-verbose -xall -xmemalign=8i -y-xmemalign=8i -f77=%all -y-xdbggen=no%stabs+dwarf2 -y-xdbggen=incl -xassume_control=optimize -y-xassume_control=optimize -iorounding=processor-defined -xhasc=yes hello.f
hello.f:
 MAIN hellow:
### f90: Note: LD_LIBRARY_PATH = (null)
### f90: Note: LD_RUN_PATH     = (null)
### f90: Note: LD_OPTIONS = (null)
/usr/ccs/bin/ld -t -R/opt/SUNWspro/lib/sparc:/opt/SUNWspro/lib -o a.out /opt/SUNWspro/prod/lib/crti.o /opt/SUNWspro/prod/lib/crt1.o /opt/SUNWspro/prod/lib/misalign.o /opt/SUNWspro/prod/lib/values-xi.o -Y P,/opt/SUNWspro/lib/sparc:/opt/SUNWspro/prod/lib/sparc:/opt/SUNWspro/lib:/opt/SUNWspro/prod/lib:/usr/ccs/lib:/lib:/usr/lib hello.o -lf77compat -lfui -lfai -lfai2 -lfsumai -lfprodai -lfminlai -lfmaxlai -lfminvai -lfmaxvai -lfsu -lsunmath -Bdynamic -lmtsk -lm -lc /opt/SUNWspro/prod/lib/crtn.o
rm hello.o

'f90 -v hello.f'실행 결과

amos $ f90 -v hello.f
###     command line files and options (expanded):
### -v hello.f
### f90: Note: NLSPATH = /opt/SUNWspro/prod/bin/../lib/locale/%L/LC_MESSAGES/%N.cat:/opt/SUNWspro/prod/bin/../../lib/locale/%L/LC_MESSAGES/%N.cat
/opt/SUNWspro/prod/bin/f90comp -y-o -yhello.o -ev -y-ftrap=common -m3 -dq -y-fbe -y/opt/SUNWspro/prod/bin/fbe -y-xarch=generic -y-s -H "/opt/SUNWspro/prod/bin/f90 -v " -y-xcache=generic -xcache=generic -I/opt/SUNWspro/prod/include/f95/v8 -p/opt/SUNWspro/prod/lib/modules -y-verbose -xall -xmemalign=8i -y-xmemalign=8i -y-xdbggen=no%stabs+dwarf2 -y-xdbggen=incl -xassume_control=optimize -y-xassume_control=optimize -iorounding=processor-defined -xhasc=yes hello.f
### f90: Note: LD_LIBRARY_PATH = (null)
### f90: Note: LD_RUN_PATH     = (null)
### f90: Note: LD_OPTIONS = (null)
/usr/ccs/bin/ld -t -R/opt/SUNWspro/lib/sparc:/opt/SUNWspro/lib -o a.out /opt/SUNWspro/prod/lib/crti.o /opt/SUNWspro/prod/lib/crt1.o /opt/SUNWspro/prod/lib/misalign.o /opt/SUNWspro/prod/lib/values-xi.o -Y P,/opt/SUNWspro/lib/sparc:/opt/SUNWspro/prod/lib/sparc:/opt/SUNWspro/lib:/opt/SUNWspro/prod/lib:/usr/ccs/lib:/lib:/usr/lib hello.o -lfui -lfai -lfai2 -lfsumai -lfprodai -lfminlai -lfmaxlai -lfminvai -lfmaxvai -lfsu -lsunmath -Bdynamic -lmtsk -lm -lc /opt/SUNWspro/prod/lib/crtn.o
rm hello.o

F77을 사용한 성공적인 컴파일의 결과 :

amos $ make
mksh: Warning: newline is not last character in file Makefile
Current working directory /u/f/osv20/Y4-UNIX/complete
g++ -c -o main.o main.cpp
In file included from main.cpp:16:
SA.h:85:9: warning: no newline at end of file
main.cpp:38:2: warning: no newline at end of file
g++ -c -o SA.o SA.cpp
In file included from SA.cpp:22:
SA.h:85:9: warning: no newline at end of file
In file included from SA.cpp:23:
CFE.h:25:8: warning: no newline at end of file
SA.cpp:468:4: warning: no newline at end of file
g++ -c -o mersenne.o mersenne.cpp
gcc -c -o CFE.o CFE.c
In file included from BCs.h:9,
                 from CFE.c:29:
fg_types.h:38:7: warning: no newline at end of file
In file included from CFE.c:29:
BCs.h:15:84: warning: no newline at end of file
In file included from CFE.c:32:
KMatrix.h:12:171: warning: no newline at end of file
In file included from CFE.c:34:
Solve.h:9:91: warning: no newline at end of file
CFE.c: In function `CFE':
CFE.c:145: warning: `return' with a value, in function returning void
gcc -c -o BCs.o BCs.c
In file included from BCs.h:9,
                 from BCs.c:9:
fg_types.h:38:7: warning: no newline at end of file
In file included from BCs.c:9:
BCs.h:15:84: warning: no newline at end of file
BCs.c:74:2: warning: no newline at end of file
gcc -c -o EMatrix.o EMatrix.c
In file included from EMatrix.h:9,
                 from EMatrix.c:9:
fg_types.h:38:7: warning: no newline at end of file
EMatrix.c:78:2: warning: no newline at end of file
gcc -c -o Numbering.o Numbering.c
In file included from Numbering.h:8,
                 from Numbering.c:8:
fg_types.h:38:7: warning: no newline at end of file
Numbering.c:144:3: warning: no newline at end of file
gcc -c -o KMatrix.o KMatrix.c
In file included from KMatrix.h:8,
                 from KMatrix.c:9:
fg_types.h:38:7: warning: no newline at end of file
In file included from KMatrix.c:9:
KMatrix.h:12:171: warning: no newline at end of file
KMatrix.c:194:2: warning: no newline at end of file
gcc -c -o Solve.o Solve.c
In file included from Solve.c:8:
Solve.h:9:91: warning: no newline at end of file
Solve.c:95:2: warning: no newline at end of file
f77 -c -o MA_57.o MA_57.f
NOTICE: Invoking /usr/bin/f90 -f77 -ftrap=%none -c -o MA_57.o MA_57.f
MA_57.f:
        ma57i:
        ma57a:
        ma57b:
        ma57c:
        ma57q:
        ma57r:
        ma57u:
        ma57s:
        ma57t:
        ma57d:
        ma57e:
        ma57g:
        ma57j:
        ma57k:
        ma57f:
        ma57l:
        ma57m:
        ma57n:
        ma57o:
        ma57p:
        ma57w:
        ma57x:
        ma57y:
        ma57v:
        ma57h:
        ma57z:
f77 -c -o blas.o blas.f
NOTICE: Invoking /usr/bin/f90 -f77 -ftrap=%none -c -o blas.o blas.f
blas.f:
        sgemm:
        stpsv:
        isamax:
        xerbla:
        lsame:
        sgemv:
f77 -c -o MA_57_Depend.o MA_57_Depend.f
NOTICE: Invoking /usr/bin/f90 -f77 -ftrap=%none -c -o MA_57_Depend.o MA_57_Depend.f
MA_57_Depend.f:
        mc47a:
        mc47b:
        mc71a:
        mc34a:
        mc59a:
        mc59b:
        mc59c:
        mc59d:
        mc59e:
        mc59f:
        ma27i:
        ma27a:
        ma27b:
        ma27c:
        ma27g:
        ma27h:
        ma27u:
        ma27j:
        ma27k:
        ma27l:
        ma27m:
        ma27n:
        ma27o:
        ma27p:
        ma27q:
        ma27r:
        mc64i:
        mc64a:
        mc64b:
        mc64d:
        mc64e:
        mc64f:
        mc64r:
        mc64s:
        mc64q:
        mc64u:
        mc64w:
        mc21a:
        mc21b:
        fd15a:
f77 -c -o Metis.o Metis.f
NOTICE: Invoking /usr/bin/f90 -f77 -ftrap=%none -c -o Metis.o Metis.f
Metis.f:
        metis_nodend:
f77 -L/usr/sfw/lib -R/usr/sfw/lib -lgcc_s -lstdc++ -o SlowDynamic.exe main.o \
        SA.o mersenne.o CFE.o MA_57.o blas.o MA_57_Depend.o Metis.o\
        BCs.o EMatrix.o Numbering.o KMatrix.o Solve.o
NOTICE: Invoking /usr/bin/f90 -f77 -ftrap=%none -L/usr/sfw/lib -R/usr/sfw/lib -lgcc_s -lstdc++ -o SlowDynamic.exe main.o SA.o mersenne.o CFE.o MA_57.o blas.o MA_57_Depend.o Metis.o BCs.o EMatrix.o Numbering.o KMatrix.o Solve.o
도움이 되었습니까?

해결책

어떤 버전의 GCC를 사용하고 있습니까? GCC의 Fortran 컴파일러는 시간이 지남에 따라 완전히 변경되었습니다 (G77 vs Gfortran) - 정답은 정확한 버전에 매우 의존합니다. 이 작업을해야했던 이래로 오래되었습니다 (그리고 오래된 G77 버전을 사용 했으므로 상황이 바뀌었을 수도 있습니다). 그러나 당시 몇 가지 옵션을 기억합니다.

  • G77을 사용하여 링크를 시도하고 라이브러리 -LSTDC ++ (및 아마도 -lm?)를 포함하십시오.
  • g ++를 사용하여 링크를 시도하고 라이브러리 -LG2C -LM (및 아마도 -lfrtbegin?)을 포함시킵니다.

최신 gfortran을 사용하는 경우 -lgfortran은 gfortran과 링크하는 경우 g ++ 및 -lstdc ++와 링크하는 경우 작동해야합니다.

또한 MakeFile의 G ++ 및 F77 명령이 실행중인 명령을 실행하고 있는지 확인하려고합니다 (예 : 예기치 않은 디렉토리 또는 다른/호환 버전에서 실행 파일에 액세스하지 않음).

편집 : 최근 편집에서 질문에 이르기까지 Sun Compiler의 F77을 GCC G ++와 연결하려고하는 것으로 보입니다. 나는 이것이 가능하지 않다고 생각합니다. Sun F77 대신 GCC의 G77 또는 Gfortran을 사용해보십시오.

다른 팁

Raugnar,

나는 당신을 추천합니다 내 대답 해결되지 않은 기호에 대한 이전 질문에.

그냥 실행 :

f77 -v something.f

독립형 FORTRAN90 프로그램에서 컴파일러는 기본적으로 어떤 지원 라이브러리가 연결되는지 정확하게 밝혀집니다.

Fortran에는 "표준 라이브러리"가 없습니다. 그것은 많은 고유 기능을 가지고 있지만 표준에 의해 정의 된 언어의 일부입니다.


주석 필드는 문자 수와 관련하여 너무 제한적이므로 의견에 대한 답변입니다.

@Michael- 네, 그렇게 말할 수 있습니다. 그러나 여전히, 그것은 당신이 아마도 익숙한 다른 언어와 동일하지 않습니다. 내 말은 이것입니다. Fortran 프로그램을 컴파일하고 빌드 할 때 컴파일러 또는 링커는 프로세스에 라이브러리를 포함 할 필요가 없습니다. 컴파일러의 내부 사항입니다. 이것은 "표준"함수 (Intrinsics and Ant)에 적용됩니다.

외부 기능이나 서브 루틴 (예 : 일부 플로팅 루틴)을 사용하는 경우 별도로 포함해야합니다.

그러나 언어의 일부인 표준 수학적 기능을 사용하는 경우 작업이 완료됩니다. 당신은 당신의 프로그램을 작성하고 그것을 컴파일하고 빌드합니다. 해당 함수가 어디에서 어떻게 구현되는지, 구현이 저장되는지 등을 알 필요가 없습니다. 그것이 컴파일러의 작업입니다.

마지막으로 모든 사람들의 조언을 혼합하여 솔루션을 수정했습니다.

GCC 대신 SUN을 사용하고 있다는 것을 깨달았을 때 CC (GCC), CC (G ++) 및 F95 (F77)로 컴파일하는 것으로 전환했습니다.

문제를 해결 한 것은 F77 Verbose 피드백 (메인 포스트의 위)에서 전체 링커 라인에 붙여 넣고 기여하지 않은 부분을 점차 삭제하는 것이 었습니다. 결국 다음 텍스트가 추가되었습니다.

-t -r/opt/sunwspro/lib/sparc :/opt/sunwspro/lib -yp,/opt/sunwspro/lib/sparc :/opt/sunwspro/prod/lib/sparc :/sunwspro/lib :/ opt/sunwspro/prod/lib :/usr/ccs/lib :/lib :/lib :/usr/lib -lfui -lfai -lfai2 -lfsumai -lfprodai -lfminlai -lfmaxlai -lfminvai -lfmaxvai -lfsu -lsunmath-bdynamic -bdynamatamai -LC

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top