Problem to call fortran from C with linux ifc/gcc

From: Ben (broger_at_oreka.com)
Date: 12/09/03


Date: 9 Dec 2003 14:40:15 GMT

Hello,

I tried without succes to call a Fortran subroutine with a C program in
a very simple program:

mod_fortran.f90:
module mod_fortran
  public :: fct_fortran
  contains
     subroutine fct_fortran()
         print *,"FORTRAN"
     end subroutine fct_fortran
end module mod_fortran
--------------------------------------
test.c :
main() {
fct_fortran();
}
---------------------------------------

To compile I used
ifc -c -nus mod_fortran.f90
cc -c test.c
ifc test.o mod_fortran.o

and I get the error compilation :

undefined reference to `fct_fortran'

I tried to see the reference in the .o:

nm test.o :
        U fct_fortran

nm mod_fortran.o:
00000000 T mod_fortran..fct_fortran

Someone has an idea to compile my program ? It seems that the program ca
n't make the link between mod_fortran..fct_fortran and fct_fortran ...

Regards

Ben

=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
Article poste via Voila News - http://www.news.voila.fr
Le : Tue Dec 9 15:40:15 2003 depuis l'IP : icare-pc2.univ-lille1.fr [VIP 403146271547]



Relevant Pages

  • Re: GETARG in ifc
    ... Here's the code, compile line and ... bash$ ifc t.f90 -Vaxlib ... /tmp/ifcNmTVkg.o: undefined reference to `getarg_' ...
    (comp.lang.fortran)
  • Re: Problem to call fortran from C with linux ifc/gcc
    ... > I tried without succes to call a Fortran subroutine with a C program in ... > subroutine fct_fortran ... > undefined reference to `fct_fortran' ... > Someone has an idea to compile my program? ...
    (comp.lang.fortran)
  • Libraries on Linux
    ... trying to compile with ifc and link to the WSMP on a Linux RedHat ... frontsetup.o: undefined reference to ...
    (comp.lang.fortran)
  • Re: Prolog & C linking Problem
    ... >> I am trying to compile Prolog and C using plld. ... PL_initialise_ is an undefined reference ...
    (comp.lang.prolog)
  • Re: error message while compiling engdemo.c
    ... As I have never done it before, I try to compile examples given on the matlab documentation: ... engdemo.c:: undefined reference to `engPutVariable' ... engdemo.c:: undefined reference to `engEvalString' ... For Fortran, follow similar steps as above but select the Fortran compiler and use the appropriate Fortran engmatopts.bat file. ...
    (comp.soft-sys.matlab)