I'm trying to create language bindings for a message passing interface but the compiler can't recognize my reference to the C functions...
I'm currently using gfortran as my compiler on a linux machine... I know the language bindings work, but whenever I try to link them to the mpi library, I get this error:
/tmp/ccwukrNT.o: In function `MAIN__':
hello_init.f90:(.text+0x17): undefined reference to `mpi_init'
collect2: error: ld returned 1 exit status
the commands to compile I am currently using are:
gfortran -ffree-form foo.f90 ~/dir1/dir2/bar.f90 -o <outfile> -L
/home/.fakeroot/lib -I /home/.fakeroot/include/ -lexampi
(exampi is the standard I am currently working on)
As I said, when I use simple hello_world programs and compile all my files manually, this method works, but it fails when I try and link it to a library. Can anyone help me?
here is my current Fortran binding for MPI_Init:
module mpi_f08
interface MPI_Init
subroutine MPI_Init(ierror) bind(C)
integer, optional, intent(out) :: ierror
end subroutine MPI_Init
end interface MPI_Init
end module mpi_f08
The C function I am using is trivial... it's merely interfacing with PMPI_Init()... In any event, the library linking is the main problem... Yes, I have externalized it from C++.
Here is the simple test program I wrote:
program hello_init
use mpi_f08, only : MPI_Init
implicit none
integer :: ierror
ierror = 0
call MPI_Init(ierror)
stop
end program hello_init
I am not too familiar with Fortran... this was given to me as a side project but it's quickly taking up my whole week simultaneously laughs and cries
Thanks!