主要想用MODULE定义全局变量,怎么将该MODULE封装成DLL?
遇到报错的做法:
(1)以moddll名称建立dll,并编译,在debug找到并copy编译得到的moddll.mod和moddll.dll
module modDLL
implicit none
real*8 a
end module modDLL
(2)建立project,编译成功
program main
implicit none
real*8 a
a=1.d0
end
(3)将moddll.mod和moddll.dll放入project的debug中,并在main程序中use模块
program main
use moddll ! 使用模块
implicit none
real*8 a
a=1.d0
end
(4)后编译,出现报错:Error: The attributes of this name conflict with those made accessible by a USE statement. [A]
(5)去掉real*8 a,再编译,报错1:error LNK2001: unresolved external symbol _MODDLL_mp_A。报错2:fatal error LNK1120: 1 unresolved externals
program main
use moddll
implicit none
a=1.d0
end
报错1和报错2应该都归由报错1,即主要的问题是:unresolved external symbol _MODDLL_mp_A。