Re: using dot_product from c++



In article <1202944737_13505@xxxxxxxxxxxxxxxxxxxxx>,
"Gerry Ford" <invalid@xxxxxxxxxxx> writes:

"Craig Powers" <enigma@xxxxxxxxxx> wrote in message
news:47b34bd4$0$29924$a726171b@xxxxxxxxxxxxxxxxxx
utab wrote:

+ Second question(just curious about to give a try to file processing)
is that if I would like to write the result inside the fortran
subroutine, I am uncommenting the 3 lines related to file operation,
and compiling and linking fine but there is still a problem with the
IO differences between two programming languages I guess(not sure
though)

vecpro.o: In function `vectorproduct_':
vecpro.f90:(.text+0xcb): undefined reference to `_gfortran_st_open'
vecpro.f90:(.text+0x101): undefined reference to `_gfortran_st_write'
vecpro.f90:(.text+0x11e): undefined reference to
`_gfortran_transfer_real'
vecpro.f90:(.text+0x12c): undefined reference to
`_gfortran_st_write_done'
vecpro.f90:(.text+0x162): undefined reference to `_gfortran_st_close'
collect2: ld returned 1 exit status

I should still link some fortran related library I guess, but not so
sure, could you please direct me to right locations for the above
questions?

You need to either link using gfortran (instead of g++), or link against
the appropriate libraries; at a minimum, I think you'd need -lgfortran,
but there might be another one necessary to do initialization.

I think what you're suggesting is that the third line look different.
gfortran -c vecpro.f90
g++ -c vecprod.cc
g++ -o test vecpro.o vecprod.o -lg2c

Steve already mentioned that -lg2c was suspect.

It's not suspect. It is wrong. At a minimum you
need -lgfortran. But that may not be sufficient
because g++ may not (more likely does not) properly
set up the gfortran runtime environment.

Apparently, the gcc linker is unconcerned with filetypes. How does one know
what libraries one needs in a simple handoff of two vectors in a calculation
that either syntax could pull off by itself?

gcc -v
gfortran -v
g++ -v

These commands will show the gory details.

--
Steve
.



Relevant Pages

  • Re: using dot_product from c++
    ... + Second question(just curious about to give a try to file processing) ... I should still link some fortran related library I guess, ... You need to either link using gfortran, ... This is what the libraries are in the root folder of lib: ...
    (comp.lang.fortran)
  • Re: Allocatable arrays and shared libraries: help needed
    ... linux you have to name the library as libLIBRARYNAME.a whereas in Win ... if you said you understood anything about building libraries ... and linking with gfortran it would have been evidence that you were ... make the decoration in a limited number of cases, ...
    (comp.lang.fortran)
  • problem of building stardict
    ... checking for gcc... ... checking for C compiler default output file name... ... checking how to recognize dependent libraries... ... checking for gfortran... ...
    (Fedora)
  • Re: best software environment for numerical analysis
    ... GNU gcc-4.0 will include gfortran instead of g77. ... libraries. ... octave is next best and is ... code written for Matlab runs on octave, ...
    (sci.math.num-analysis)
  • Re: Help linking f77 libraries into gfortran
    ... been testing the gfortran compiler and ran across a problem linking f77 ... libraries to use in gfortran. ...
    (comp.lang.fortran)