我在通过自制软件安装了 Xcode 5.0.2 和 gfortran 4.8.2 的 OS X 10.8 系统上收到以下错误消息。
% gfortran -shared f03_iso_c.f03
ld: illegal text-relocation to '_compute' in /var/folders/w3/_r4gjs1d363176f99wgkpwl80000gn/T//cc8VFCuI.o from 'anon' in /var/folders/w3/_r4gjs1d363176f99wgkpwl80000gn/T//cc8VFCuI.o for architecture x86_64
collect2: error: ld returned 1 exit status
f03_iso_c.f03 的内容是
module F03_ISO_C
use, intrinsic :: iso_c_binding
contains
integer(c_int) function compute() bind(c) result(compute)
use, intrinsic :: iso_c_binding
implicit none
compute = 1
return
end function compute
end module F03_ISO_C
integer function F03_ISO_C_init()
use F03_ISO_C
use, intrinsic :: iso_c_binding
implicit none
call USE_FUNC_PTR(c_funloc(compute))
F03_ISO_C_init = 1
return
end function F03_ISO_C_init
subroutine USE_FUNC_PTR(f1)
use, intrinsic :: iso_c_binding
implicit none
type(c_funptr) :: f1
print *, f1, "is the address"
end subroutine USE_FUNC_PTR
任何解决此错误的帮助将不胜感激。