编译并链接Fortran和C mac

时间:2015-01-07 20:55:26

标签: c fortran

这是我的C程序(c_routine.c):

#include <stdio.h>
#include <stdlib.h>

void fortfunc_(int *ii, float *ff);

int main()
{
   int ii           = 5;
   float ff         = 5.5;

   fortfunc_(&ii, &ff);

   return 0;
}

这是我的Fortran子程序(fortran_routine.c):

subroutine fortfunc(ii,ff)
     integer ii
     real*4  ff

     write(6,100) ii, ff
100  format('ii=',i2,' ff=',f6.3)

     return
end

我的编译步骤:

gfortran -c fortran_routine.f90 -o fortran_routine -ld
gcc -c c_routine.c
gcc -o test fortran_routine.o c_routine.o -ld

最后一步虽然给了我错误:

ld: library not found for -ld
clang: error: linker command failed with exit code 1 (use -v to see invocation)

这是-ld?

的错误

0 个答案:

没有答案