Quantcast
Channel: Intel® Fortran Compiler for Linux* and macOS*
Viewing all articles
Browse latest Browse all 2583

Compilation error while using iso_c_binding in Mix-language code.

$
0
0
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");
 }

 


Viewing all articles
Browse latest Browse all 2583

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>