Windows에서 Fortran 프로젝트 (사실 Fortran + C) 용 DLL을 생성하고 싶습니다. dll이 다른 DLL에 의존 할 때 Linux에서 만나지 않는 문제가 발생합니다.Windows에서 gfortran을 사용하여 DLL을 생성하십시오.
이module dll1
implicit none
contains
subroutine test1
write(*,*) "test1 ok"
end subroutine
end module
파일 dll2.f90이
이module dll2
use dll1,only : test1
implicit none
contains
subroutine test2
call test1
end subroutine
end module
파일 main.f90이
이program main
use dll2, only : test2
implicit none
call test2
end program
리눅스 명령
파일 dll1.f90 (: 여기
짧은 예이다 파일 실행. 배시)gfortran -shared -fPIC -o libdll1.so dll1.f90
gfortran -shared -fPIC -o libdll2.so dll2.f90
gfortran -o main.exe main.f90 -I. -L. -ldll2 -ldll1
export LD_LIBRARY_PATH="./"
./main.exe
윈도우 (파일 run.bat를) Windows에서
gfortran -shared -fPIC -o dll1.dll dll1.f90
gfortran -shared -fPIC -o dll2.dll dll2.f90
gfortran -o main.exe main.f90 -I. -L. -ldll2 -ldll1
.\main.exe
, 나는 두 번째 명령에서 첫 번째 오류 메시지가 명령 :
__dll1_MOD_test1 (LD 메시지)에 정의되지 않은 참조
I은 제 2 명령과 같은 수정이 문제를 해결할 수있다
gfortran -shared -fPIC -o dll2.dll dll2.f90 -L . -ldll1
을하지만이 수정이 여러 가지 이유로 편리하지 않습니다 : 다음
dll을 여러 DLL을에 의존하는 경우
, 그때 그 크기가 매우 큰이된다 (모든 하위 DLL을 포함 할 것)실행 프로그램의 크기가 큰뿐만 아니라
내가 고전 라이브러리를 사용하여 훨씬 더 합리적인 결과를 얻을 수있다
리눅스 파일 크기 DLL을 대신 :
[[email protected] dll]$ ls -al
total 68
drwxrwxr-x 2 coul coul 4096 29 déc. 12:09 .
drwxrwxr-x. 7 coul coul 4096 29 déc. 11:46 ..
-rw-rw-r-- 1 coul coul 118 29 déc. 11:25 dll1.f90
-rw-rw-r-- 1 coul coul 204 29 déc. 12:09 dll1.mod
-rw-rw-r-- 1 coul coul 132 29 déc. 11:29 dll2.f90
-rw-rw-r-- 1 coul coul 237 29 déc. 12:09 dll2.mod
-rwxrwxr-x 1 coul coul 8184 29 déc. 12:09 libdll1.so
-rwxrwxr-x 1 coul coul 7920 29 déc. 12:09 libdll2.so
-rwxrwxr-x 1 coul coul 8712 29 déc. 12:09 main.exe
-rw-rw-r-- 1 coul coul 82 29 déc. 11:27 main.f90
-rwxrwxr-x 1 coul coul 183 29 déc. 11:38 run.bash
-rw-rw-r-- 1 coul coul 151 29 déc. 11:55 run.bat
Windows 파일이 크기
29/12/2017 11:53 <DIR> .
29/12/2017 11:53 <DIR> ..
29/12/2017 11:53 2 264 764 dll1.dll
29/12/2017 11:25 118 dll1.f90
29/12/2017 11:50 204 dll1.mod
29/12/2017 11:53 51 814 dll2.dll
29/12/2017 11:29 132 dll2.f90
29/12/2017 11:50 237 dll2.mod
29/12/2017 11:53 2 264 671 main.exe
29/12/2017 11:27 82 main.f90
29/12/2017 11:38 183 run.bash
29/12/2017 11:53 162 run.bat
그래서 제 질문은 : 이러한 단점을 해결하는 방법을?