首页 > 解决方案 > 封装静态库中的 C 函数时,flag 找不到 iso_c_bindings

问题描述

我有一个用 C 编写的静态库mylib.a,我正在尝试从 Fortran 首次调用 C。

我想在 Fortran 中调用 C 库中包含的以下函数:

double get_step(double value); 

我尝试以下 Fortran 代码:

! TEST FORTRAN WRAPPER

module test

        use, intrinsic  :: iso_c_binding

        ! Interface to C routine
        ! double get_step(double value);
        interface
                real(c_double) function _get_step(value) bind(C, 'get_step')
                        use, intrinsic :: iso_c_binding, only : c_double
                        real(c_double) :: value
                end function
        end interface

end module

我尝试像这样编译它:

$ flang test.f90 mylib.a
F90-F-0004-Unable to open MODULE file iso_c_binding.mod (test.f90: 5)
F90/x86-64 FreeBSD Flang - 1.5 2017-05-01: compilation aborted

标签: fortranfortran-iso-c-bindingflang

解决方案


推荐阅读