Fortran shared library 똑똑하기




1. Main : test.f90

PROGRAM MAIN

!DEC$ATTRIBUTES DLLIMPORT::HELLODLLRUTINE1

!DEC$ATTRIBUTES DLLIMPORT::HELLODLLRUTINE2

CALL HELLODLLRUTINE1()

CALL HELLODLLRUTINE2()

 

END PROGRAM



2. Shared Library 1 : testdll1.f90

SUBROUTINE HELLODLLRUTINE1()

!DEC$ATTRIBUTES DLLEXPORT::HELLODLLRUTINE1

 

PRINT *, "HELLOWORLD FROM FIRST SHARED LIBRARY"

 

END SUBROUTINE



3. Shared Library 2 : testdll2.f90

SUBROUTINE HELLODLLRUTINE2()

!DEC$ATTRIBUTES DLLEXPORT::HELLODLLRUTINE2

 

PRINT *, "HELLOWORLD FROM SECOND SHARED LIBRARY"

 

END SUBROUTINE



4. Compile


-Windows
$ gfortran -c testdll1.f90 testdll2.f90

$ gfortran -shared -o testdll.dlltestdll1.o testdll2.o

$ gfortran test.f90 testdll.dll


-Linux
$ gfortran -c testdll1.f90 testdll2.f90

$ gfortran -shared -o testdll.so testdll1.o testdll2.o

$ gfortran test.f90 testdll.so



덧글

댓글 입력 영역


메모장