I am trying to use the c_ptr and c_loc of the iso_c_binding module, but a compilation errer is reported: "undefined reference to `iso_c_binding_mp_c_loc_'" The compile commands I ues are: ifort -c sub.f90 icc -c main.c icc main.o sub.o And here follows my code.
module try_ptr
contains
subroutine test() bind(c)
use iso_c_binding,only : c_loc,c_ptr,c_int
implicit none
type(c_ptr) :: mptr
integer(c_int) :: mj(10)
mptr=c_loc(mj(1))
return
end subroutine test
end module try_ptr#include <stdio.h>
int main()
{
printf("test\n");
}