C++/Fortran mixing

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • NM

    C++/Fortran mixing

    Hi all
    I am trying to link C++ and Fortran.I am not very familiar with Fortran.
    I have been successful in linking C++ and fortran using g++ and ifc for
    simple program. So adding _ to at the end of fortran subroutine names when
    calling from C++ is working. Now I want to move to bigger program. I have a
    rather big Fortran code which compiles and links fine under ifc. Now I
    changed the program main in Fortran into a subroutine main_sub so that I can
    call this subroutine main_sub from C++. I am getting error in linking. For
    your convenience I am pasting the output of both linking the main program in
    ifc and linking the program with g++. Any help will be appreciated regarding
    the undefined reference. Thanks

    NM

    linking the main program in ifc
    ------------------------------

    workstation:~/1D> make
    ifc -o a.out ./module/control.o ./module/typed.o ./module/data_structure1 D.o
    ../module/h_refinements.o ./module/typehp.o ./module/hp_refinements. o
    ../module/frsolmod.o ./module/interpolation.o ./module/tree.o ./main/main.o
    ../main/main_sub.o ./main/read_control.o ./constr_util/history.o
    ../constr_util/history2.o ./constr_util/setcnstr.o ./data/exact.o
    ../data/getc.o ./data/getd.o ./data/getf.o ./data/get_values.o
    ../data/write_values.o ./data/get_nreles.o ./data/get_nreles2.o ./data/getg.o
    ../data/getmat.o ./datstrs/dumpin.o ./datstrs/dumpout.o ./datstrs/faminf.o
    ../datstrs/faminf2.o ./datstrs/findap.o ./datstrs/findap2.o
    ../datstrs/nelcon.o ./datstrs/nelcon2.o ./datstrs/nodcor.o
    ../datstrs/nodcor2.o ./datstrs/result.o ./datstrs/solelm2.o
    ../datstrs/solelm.o ./elem_util/const.o ./elem_util/shape1.o
    ../meshgen/allocds.o ./meshgen/deallocds.o ./meshgen/meshgen.o
    ../solver1/preout.o ./solver1/solin1.o ./solver1/solin2.o ./solver1/solout.o
    ../mysolver/mysolver.o ./solver1/solve1.o ./laplace/elem.o
    ../laplace/elem_info.o ./laplace/elem_matrix.o ./laplace/elem_ld.o
    ../laplace/elem_bc.o ./laplace/elem_error.o ./laplace/elem_error2.o
    ../laplace/elem_load.o ./laplace/error_contr.o ./laplace/error_contr2.o
    ../laplace/load_contr.o ./meshmods/break.o ./meshmods/break2.o
    ../meshmods/break_mdle.o ./meshmods/break_mdle2.o ./meshmods/cluster_mdle.o
    ../meshmods/cluster_mdle2.o ./meshmods/nodmod2.o ./meshmods/nodmod.o
    ../graph_1D/display_error.o ./graph_1D/graph.o ./graph_1D/graph1D.o
    ../graph_1D/graph1D_zoom.o ./graph_1D/rates.o ./graph_util/arctan.o
    ../graph_util/clip_line.o ./graph_util/clip_poly.o ./graph_util/colorset.o
    ../graph_util/dpbox.o ./graph_util/draw_line.o ./graph_util/finstr.o
    ../graph_util/initwin.o ./graph_util/mat3prod.o ./graph_util/selwin.o
    ../graph_interf/closwind.o ./graph_interf/clrwind.o ./graph_interf/drawline.o
    ../graph_interf/fillpoly.o ./graph_interf/flushx.o ./graph_interf/initcm.o
    ../graph_interf/openwind.o ./graph_interf/selwind.o ./graph_interf/setpost.o
    ../graph_interf/symbol.o ./graph_interf/wverr.o ./graph_interf/wvwarn.o
    ../graph_interf/inout.o ./graph_interf/psgr.o ./graph_interf/xglibf.o
    ../utilities/findmax.o ./utilities/locate.o ./utilities/opfil.o
    ../utilities/pause.o ./blas/blas.o ./blas/gausse.o ./blas/rhsub.o
    ../blas/tri.o ./blas/zrhsub.o ./frontsol/bckwrd.o ./frontsol/complt.o
    ../frontsol/dest.o ./frontsol/desvec.o ./frontsol/elmrhs.o
    ../frontsol/elmsol.o ./frontsol/frwcp.o ./frontsol/frwrs.o ./frontsol/locls.o
    ../frontsol/loclu.o ./frontsol/locr.o ./frontsol/resol.o ./frontsol/semrhs.o
    ../frontsol/surfsp.o ./frontsol/surfss.o ./frontsol/symasm.o
    ../frontsol/symelm.o ./frontsol/unsasm.o ./frontsol/unselm.o
    ../frontsol/zdirio.o ./frontsol/zecond.o ./frontsol/zeror.o
    ../frontsol/zeros.o ./frontsol/zerou.o ./adapt_hp/compute_error.o
    ../adapt_hp/print_nodes.o ./adapt_hp/get_values_1_co mpute_error.o
    ../adapt_hp/get_values_2_co mpute_error.o
    ../adapt_hp/write_values_co mpute_error.o
    ../adapt_hp/get_values_1_gl obal_hpref.o
    ../adapt_hp/get_values_2_gl obal_hpref.o
    ../adapt_hp/write_values_gl obal_hpref.o ./adapt_hp/get_values_1_hp _elements.o
    ../adapt_hp/get_values_2_hp _elements.o ./adapt_hp/write_values_hp _elements.o
    ../adapt_hp/element1D_error .o ./adapt_hp/element_ext.o
    ../adapt_hp/global_hpref.o ./adapt_hp/hp_elements.o ./adapt_hp/hp_strategy.o
    ../adapt_hp/increase_order. o ./adapt_hp/optimize.o ./adapt_hp/precompute.o
    ../adapt_hp/project_element .o ./adapt_h/compute_herror. o
    ../adapt_h/h_strategy.o -L/usr/X11R6/lib -lX11 -lIEPCF90

    No error and a.out is generated.


    linking using ifc and g++
    ------------------------

    workstation:~/temp/t/test_1d_fortran/psl_fortran.mpi > make
    g++ -DMPI -g -I/u/user1/code2/lib/runtime/unified -I/u/user1/mpi-1.2.5/inc
    lude -c c2_main.cpp
    g++ -DMPI -g -I/u/user1/code2/lib/runtime/unified -I/u/user1/mpi-1.2.5/inc
    lude -c main.cpp
    mpiCC c2_main.o main.o /u/user1/ICES/1D/module/control.o
    /u/user1/ICES/1D/module/typed.o /u/user1/ICES/1D/module/data_structure1 D.o
    /u/user1/ICES/1D/module/h_refinements.o /u/user1/ICES/1D/module/typehp.o
    /u/user1/ICES/1D/module/hp_refinements. o /u/user1/ICES/1D/module/frsolmod.o
    /u/user1/ICES/1D/module/interpolation.o /u/user1/ICES/1D/module/tree.o
    /u/user1/ICES/1D/main/main_sub.o /u/user1/ICES/1D/main/read_control.o
    /u/user1/ICES/1D/constr_util/history.o
    /u/user1/ICES/1D/constr_util/history2.o
    /u/user1/ICES/1D/constr_util/setcnstr.o /u/user1/ICES/1D/data/exact.o
    /u/user1/ICES/1D/data/getc.o /u/user1/ICES/1D/data/getd.o
    /u/user1/ICES/1D/data/getf.o /u/user1/ICES/1D/data/get_values.o
    /u/user1/ICES/1D/data/write_values.o /u/user1/ICES/1D/data/get_nreles.o
    /u/user1/ICES/1D/data/get_nreles2.o /u/user1/ICES/1D/data/getg.o
    /u/user1/ICES/1D/data/getmat.o /u/user1/ICES/1D/datstrs/dumpin.o
    /u/user1/ICES/1D/datstrs/dumpout.o /u/user1/ICES/1D/datstrs/faminf.o
    /u/user1/ICES/1D/datstrs/faminf2.o /u/user1/ICES/1D/datstrs/findap.o
    /u/user1/ICES/1D/datstrs/findap2.o /u/user1/ICES/1D/datstrs/nelcon.o
    /u/user1/ICES/1D/datstrs/nelcon2.o /u/user1/ICES/1D/datstrs/nodcor.o
    /u/user1/ICES/1D/datstrs/nodcor2.o /u/user1/ICES/1D/datstrs/result.o
    /u/user1/ICES/1D/datstrs/solelm2.o /u/user1/ICES/1D/datstrs/solelm.o
    /u/user1/ICES/1D/elem_util/const.o /u/user1/ICES/1D/elem_util/shape1.o
    /u/user1/ICES/1D/meshgen/allocds.o /u/user1/ICES/1D/meshgen/deallocds.o
    /u/user1/ICES/1D/meshgen/meshgen.o /u/user1/ICES/1D/solver1/preout.o
    /u/user1/ICES/1D/solver1/solin1.o /u/user1/ICES/1D/solver1/solin2.o
    /u/user1/ICES/1D/solver1/solout.o /u/user1/ICES/1D/mysolver/mysolver.o
    /u/user1/ICES/1D/solver1/solve1.o /u/user1/ICES/1D/laplace/elem.o
    /u/user1/ICES/1D/laplace/elem_info.o /u/user1/ICES/1D/laplace/elem_matrix.o
    /u/user1/ICES/1D/laplace/elem_ld.o /u/user1/ICES/1D/laplace/elem_bc.o
    /u/user1/ICES/1D/laplace/elem_error.o /u/user1/ICES/1D/laplace/elem_error2.o
    /u/user1/ICES/1D/laplace/elem_load.o /u/user1/ICES/1D/laplace/error_contr.o
    /u/user1/ICES/1D/laplace/error_contr2.o
    /u/user1/ICES/1D/laplace/load_contr.o /u/user1/ICES/1D/meshmods/break.o
    /u/user1/ICES/1D/meshmods/break2.o /u/user1/ICES/1D/meshmods/break_mdle.o
    /u/user1/ICES/1D/meshmods/break_mdle2.o
    /u/user1/ICES/1D/meshmods/cluster_mdle.o
    /u/user1/ICES/1D/meshmods/cluster_mdle2.o
    /u/user1/ICES/1D/meshmods/nodmod2.o /u/user1/ICES/1D/meshmods/nodmod.o
    /u/user1/ICES/1D/graph_1D/display_error.o /u/user1/ICES/1D/graph_1D/graph.o
    /u/user1/ICES/1D/graph_1D/graph1D.o /u/user1/ICES/1D/graph_1D/graph1D_zoom.o
    /u/user1/ICES/1D/graph_1D/rates.o /u/user1/ICES/1D/graph_util/arctan.o
    /u/user1/ICES/1D/graph_util/clip_line.o
    /u/user1/ICES/1D/graph_util/clip_poly.o
    /u/user1/ICES/1D/graph_util/colorset.o /u/user1/ICES/1D/graph_util/dpbox.o
    /u/user1/ICES/1D/graph_util/draw_line.o /u/user1/ICES/1D/graph_util/finstr.o
    /u/user1/ICES/1D/graph_util/initwin.o /u/user1/ICES/1D/graph_util/mat3prod.o
    /u/user1/ICES/1D/graph_util/selwin.o
    /u/user1/ICES/1D/graph_interf/closwind.o
    /u/user1/ICES/1D/graph_interf/clrwind.o
    /u/user1/ICES/1D/graph_interf/drawline.o
    /u/user1/ICES/1D/graph_interf/fillpoly.o
    /u/user1/ICES/1D/graph_interf/flushx.o
    /u/user1/ICES/1D/graph_interf/initcm.o
    /u/user1/ICES/1D/graph_interf/openwind.o
    /u/user1/ICES/1D/graph_interf/selwind.o
    /u/user1/ICES/1D/graph_interf/setpost.o
    /u/user1/ICES/1D/graph_interf/symbol.o /u/user1/ICES/1D/graph_interf/wverr.o
    /u/user1/ICES/1D/graph_interf/wvwarn.o /u/user1/ICES/1D/graph_interf/inout.o
    /u/user1/ICES/1D/graph_interf/psgr.o /u/user1/ICES/1D/graph_interf/xglibf.o
    /u/user1/ICES/1D/utilities/findmax.o /u/user1/ICES/1D/utilities/locate.o
    /u/user1/ICES/1D/utilities/opfil.o /u/user1/ICES/1D/utilities/pause.o
    /u/user1/ICES/1D/blas/blas.o /u/user1/ICES/1D/blas/gausse.o
    /u/user1/ICES/1D/blas/rhsub.o /u/user1/ICES/1D/blas/tri.o
    /u/user1/ICES/1D/blas/zrhsub.o /u/user1/ICES/1D/frontsol/bckwrd.o
    /u/user1/ICES/1D/frontsol/complt.o /u/user1/ICES/1D/frontsol/dest.o
    /u/user1/ICES/1D/frontsol/desvec.o /u/user1/ICES/1D/frontsol/elmrhs.o
    /u/user1/ICES/1D/frontsol/elmsol.o /u/user1/ICES/1D/frontsol/frwcp.o
    /u/user1/ICES/1D/frontsol/frwrs.o /u/user1/ICES/1D/frontsol/locls.o
    /u/user1/ICES/1D/frontsol/loclu.o /u/user1/ICES/1D/frontsol/locr.o
    /u/user1/ICES/1D/frontsol/resol.o /u/user1/ICES/1D/frontsol/semrhs.o
    /u/user1/ICES/1D/frontsol/surfsp.o /u/user1/ICES/1D/frontsol/surfss.o
    /u/user1/ICES/1D/frontsol/symasm.o /u/user1/ICES/1D/frontsol/symelm.o
    /u/user1/ICES/1D/frontsol/unsasm.o /u/user1/ICES/1D/frontsol/unselm.o
    /u/user1/ICES/1D/frontsol/zdirio.o /u/user1/ICES/1D/frontsol/zecond.o
    /u/user1/ICES/1D/frontsol/zeror.o /u/user1/ICES/1D/frontsol/zeros.o
    /u/user1/ICES/1D/frontsol/zerou.o /u/user1/ICES/1D/adapt_hp/compute_error.o
    /u/user1/ICES/1D/adapt_hp/print_nodes.o
    /u/user1/ICES/1D/adapt_hp/get_values_1_co mpute_error.o
    /u/user1/ICES/1D/adapt_hp/get_values_2_co mpute_error.o
    /u/user1/ICES/1D/adapt_hp/write_values_co mpute_error.o
    /u/user1/ICES/1D/adapt_hp/get_values_1_gl obal_hpref.o
    /u/user1/ICES/1D/adapt_hp/get_values_2_gl obal_hpref.o
    /u/user1/ICES/1D/adapt_hp/write_values_gl obal_hpref.o
    /u/user1/ICES/1D/adapt_hp/get_values_1_hp _elements.o
    /u/user1/ICES/1D/adapt_hp/get_values_2_hp _elements.o
    /u/user1/ICES/1D/adapt_hp/write_values_hp _elements.o
    /u/user1/ICES/1D/adapt_hp/element1D_error .o
    /u/user1/ICES/1D/adapt_hp/element_ext.o
    /u/user1/ICES/1D/adapt_hp/global_hpref.o
    /u/user1/ICES/1D/adapt_hp/hp_elements.o
    /u/user1/ICES/1D/adapt_hp/hp_strategy.o
    /u/user1/ICES/1D/adapt_hp/increase_order. o
    /u/user1/ICES/1D/adapt_hp/optimize.o /u/user1/ICES/1D/adapt_hp/precompute.o
    /u/user1/ICES/1D/adapt_hp/project_element .o
    /u/user1/ICES/1D/adapt_h/compute_herror. o
    /u/user1/ICES/1D/adapt_h/h_strategy.o -L/u/user1/code2/lib -L/usr/X11R6/lib
    -lX11 -L/lusr/share/software/intel/compiler70/ia32/lib -lIEPCF90 -lcode_uni
    fied -o psl_fortran -lm -lpthread
    /u/user1/ICES/1D/graph_1D/rates.o: In function `rates':
    graph_1D/rates.f:118: undefined reference to `f_powdd'
    graph_1D/rates.f:118: undefined reference to `f_powdd'
    graph_1D/rates.f:155: undefined reference to `f_powdd'
    graph_1D/rates.f:157: undefined reference to `f_powdd'
    graph_1D/rates.f:157: undefined reference to `f_powdd'
    /u/user1/ICES/1D/graph_1D/rates.o:graph_1 D/rates.f:157: more undefined
    references to `f_powdd' follow
    /u/user1/ICES/1D/frontsol/dest.o: In function `dest':
    frontsol/dest.f:126: undefined reference to `f_ldnint_val'
    frontsol/dest.f:179: undefined reference to `f_ldnint_val'
    frontsol/dest.f:180: undefined reference to `f_ldnint_val'
    frontsol/dest.f:181: undefined reference to `f_ldnint_val'
    /u/user1/ICES/1D/frontsol/symelm.o: In function `symelm':
    frontsol/symelm.f:56: undefined reference to `f_ldnint_val'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_qtoi'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_eqq'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_geq'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_divq'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_addq'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_dtoq'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_ftoq'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_mulq'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_subq'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_neq'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_ltq'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_leq'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_itoq'
    /lusr/share/software/intel/compiler70/ia32/lib/libIEPCF90.so.3 : undefined
    reference to `a_floorq'
    collect2: ld returned 1 exit status
    make: *** [psl_fortran] Error 1
    workstation:~/temp/t/test_1d_fortran/psl_fortran.mpi >


  • NM

    #2
    Re: C++/Fortran mixing

    I forgot to post lines from rates.f and dest.f
    rates.f:118 dx = x_max**alpha - x_min**alpha
    dest.f:126 l = iabs(nint(Amdes t(km-1)))



    Comment

    • E. Robert Tisdale

      #3
      Re: C++/Fortran mixing

      NM wrote:[color=blue]
      >
      > I am trying to link C++ and Fortran.I am not very familiar with Fortran.
      > I have been successful in linking C++ and fortran using g++ and ifc for
      > simple program. So adding _ to at the end of fortran subroutine names when
      > calling from C++ is working. Now I want to move to bigger program. I have a
      > rather big Fortran code which compiles and links fine under ifc. Now I
      > changed the program main in Fortran into a subroutine main_sub so that I can
      > call this subroutine main_sub from C++. I am getting error in linking. For
      > your convenience I am pasting the output of both linking the main program in
      > ifc and linking the program with g++. Any help will be appreciated regarding
      > the undefined reference.[/color]

      [snip]

      Everything looks OK
      except that the link editor ld can't resolve some references.
      Most likely this is because you have neglected to include
      a [Fortran] library which defines these references.
      Your Fortran compiler ifc knows which libraries are required
      but your C++ compiler mpiCC does not.

      cd to a directory containing your Fortran libraries

      /lusr/share/software/intel/compiler70/ia32/lib/

      for example and type

      nm -o *.a *.so *.so.3 | grep a_floorq

      You should get a list of references to a_floorq.
      The ones labeled U are undefined but those labeled T are defined.
      Just include the corresponding library along with

      -lIEPCF90 -lcode_unified

      in your Makefile.

      Comment

      • NM

        #4
        Re: C++/Fortran mixing

        Thanks. It is working :-)

        "E. Robert Tisdale" <E.Robert.Tisda le@jpl.nasa.gov > wrote in message
        news:403E6A8F.9 050504@jpl.nasa .gov...[color=blue]
        > NM wrote:[color=green]
        > >
        > > I am trying to link C++ and Fortran.I am not very familiar with Fortran.
        > > I have been successful in linking C++ and fortran using g++ and ifc for
        > > simple program. So adding _ to at the end of fortran subroutine names[/color][/color]
        when[color=blue][color=green]
        > > calling from C++ is working. Now I want to move to bigger program. I[/color][/color]
        have a[color=blue][color=green]
        > > rather big Fortran code which compiles and links fine under ifc. Now I
        > > changed the program main in Fortran into a subroutine main_sub so that I[/color][/color]
        can[color=blue][color=green]
        > > call this subroutine main_sub from C++. I am getting error in linking.[/color][/color]
        For[color=blue][color=green]
        > > your convenience I am pasting the output of both linking the main[/color][/color]
        program in[color=blue][color=green]
        > > ifc and linking the program with g++. Any help will be appreciated[/color][/color]
        regarding[color=blue][color=green]
        > > the undefined reference.[/color]
        >
        > [snip]
        >
        > Everything looks OK
        > except that the link editor ld can't resolve some references.
        > Most likely this is because you have neglected to include
        > a [Fortran] library which defines these references.
        > Your Fortran compiler ifc knows which libraries are required
        > but your C++ compiler mpiCC does not.
        >
        > cd to a directory containing your Fortran libraries
        >
        > /lusr/share/software/intel/compiler70/ia32/lib/
        >
        > for example and type
        >
        > nm -o *.a *.so *.so.3 | grep a_floorq
        >
        > You should get a list of references to a_floorq.
        > The ones labeled U are undefined but those labeled T are defined.
        > Just include the corresponding library along with
        >
        > -lIEPCF90 -lcode_unified
        >
        > in your Makefile.
        >[/color]


        Comment

        • Jack Klein

          #5
          Re: C++/Fortran mixing

          On Thu, 26 Feb 2004 15:30:43 -0600, "NM" <nm@nm.com> wrote in
          comp.lang.c++:
          [color=blue]
          > Hi all
          > I am trying to link C++ and Fortran.I am not very familiar with Fortran.
          > I have been successful in linking C++ and fortran using g++ and ifc for
          > simple program. So adding _ to at the end of fortran subroutine names when
          > calling from C++ is working. Now I want to move to bigger program. I have a
          > rather big Fortran code which compiles and links fine under ifc. Now I
          > changed the program main in Fortran into a subroutine main_sub so that I can
          > call this subroutine main_sub from C++. I am getting error in linking. For
          > your convenience I am pasting the output of both linking the main program in
          > ifc and linking the program with g++. Any help will be appreciated regarding
          > the undefined reference. Thanks
          >
          > NM[/color]

          I can't speak for the group comp.lang.fortr an, but your question is
          off-topic here in comp.lang.c++. The C++ language does not define an
          interface to Fortran, or indeed any other language except C in some
          circumstances, and all such mechanisms are completely
          compiler-specific and beyond the pale here.

          If you need advice on the C++ side of things, you need to ask in a
          compiler-specific support group.

          --
          Jack Klein
          Home: http://JK-Technology.Com
          FAQs for
          comp.lang.c http://www.eskimo.com/~scs/C-faq/top.html
          comp.lang.c++ http://www.parashift.com/c++-faq-lite/
          alt.comp.lang.l earn.c-c++

          Comment

          • William Clodius

            #6
            Re: C++/Fortran mixing



            Jack Klein wrote:
            [color=blue]
            > On Thu, 26 Feb 2004 15:30:43 -0600, "NM" <nm@nm.com> wrote in
            > comp.lang.c++:
            >[color=green]
            > > Hi all
            > > I am trying to link C++ and Fortran.I am not very familiar with Fortran.
            > > I have been successful in linking C++ and fortran using g++ and ifc for
            > > simple program. So adding _ to at the end of fortran subroutine names when
            > > calling from C++ is working. Now I want to move to bigger program. I have a
            > > rather big Fortran code which compiles and links fine under ifc. Now I
            > > changed the program main in Fortran into a subroutine main_sub so that I can
            > > call this subroutine main_sub from C++. I am getting error in linking. For
            > > your convenience I am pasting the output of both linking the main program in
            > > ifc and linking the program with g++. Any help will be appreciated regarding
            > > the undefined reference. Thanks
            > >
            > > NM[/color]
            >
            > I can't speak for the group comp.lang.fortr an, but your question is
            > off-topic here in comp.lang.c++. The C++ language does not define an
            > interface to Fortran, or indeed any other language except C in some
            > circumstances, and all such mechanisms are completely
            > compiler-specific and beyond the pale here.
            > <snip>[/color]

            FWIW - Two points

            1. The only current standard conforming way to do this is via Ada. Ada 95(?)
            defines conventions to "link" with Fortran 77 and C89, so you can, in principle
            do this if you
            a. have an Ada compiler available (GNAT is widely portable and free)
            b. learn enough Ada to deal with the details of this issue.
            c. Learn the C++ C linkage conventions
            c. Have C++ and Fortran compilers compatible with the Ada compiler, e.g., g77 and
            the g++ compiler are compatible with gnat. Be aware that many Fortran codes use
            extensions of F77. g77 incorporates the omnipresent MIL-STD extensions, but few
            others. G95 is a work in progress.

            2. There will "soon" be a n Ada independent standard conforming means of doing
            this, as Fortran 2003 defines C linkage conventions, is near the end of its
            second review, and is not expectted to require a third review. Although this is
            one of the largest additions by F03 to F95, it is also perhaps the most requested
            feature, so the most recent version of "many" (anyway more than 3) F95 compilers
            already incorporate versions of these conventions (based on earlier drafts) as an
            extension.

            --

            -------------------------------------------------------------
            William B. Clodius Space & Remote Sensing Sciences
            Tech. Staff Member, ISR-2 Phone: (505) 665-9370
            Mail Stop B244 FAX: (505) 665-4414
            Los Alamos National Lab. Group office: (505) 667-5776
            Fed Ex add: Bikini Atoll Rd. Email: remove gibberish
            Los Alamos, NM 87545
            -------------------------------------------------------------


            Comment

            Working...