mixed c++ fortran code link error 
Author Message
 mixed c++ fortran code link error

The main code is by c++ and there are many fortran codes, some are
fortran77 and some are fortran90. On linux, I tried to use g++ and
gfortran to compile and link them. As linking, there are numerous erros
like
... undefined reference to '_gfortran_ioparm'
... undefined reference to '_gfortran_line'
...
The link flags are  -lm -lstdc++
I guess I need to link to the correct libraries of gfortran. For
fortran77, I know to use -lf2c. But for fortran90, I don't know what to
do. I tried -lgfortran, it reported cannot find -lgfortran.
Anyone knows that reason for my problem?


Tue, 25 Nov 2008 23:50:55 GMT  
 mixed c++ fortran code link error
Quote:

> The main code is by c++ and there are many fortran codes, some are
> fortran77 and some are fortran90. On linux, I tried to use g++ and
> gfortran to compile and link them. As linking, there are numerous erros
> like
> ... undefined reference to '_gfortran_ioparm'
> ... undefined reference to '_gfortran_line'
> ...
> The link flags are  -lm -lstdc++
> I guess I need to link to the correct libraries of gfortran. For
> fortran77, I know to use -lf2c. But for fortran90, I don't know what to
> do. I tried -lgfortran, it reported cannot find -lgfortran.
> Anyone knows that reason for my problem?

You would use -lf2c only with a fortran77 which uses the f2c translator.
  As that hasn't had much support in recent years, it seems a strange
recommendation.
If you use gfortran to link, and have the paths set up correctly so that
it finds the libraries with the same version as the gfortran compiler,
you don't need any -l option for Fortran libraries.  The error you quote
could come from linking gfortran against an out of date library.  If you
are using a g++ of the same version as your gfortran, -lgfortran should
work without an additional -L designation. But you should need to add
-lstdc++ only if you use gfortran to drive the link, and you should
require -lm only with a gcc link.


Wed, 26 Nov 2008 00:58:04 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. troubles with fortran/c++ mixed linking.

2. Linking Fortran object code to C++ Code

3. Open mixed code Fortran/C++

4. Mixing Fortran and C++ codes using SUN f77 V1.4

5. Mixing Lisp code and C/C++ code

6. Statically linking Fortran code to Visual C++

7. Linking Fortran and C++ code using SUN CC

8. HELP -- LINKING BORLAND C++ WITH FORTRAN CODE

9. Linking Fortran and C/C++ Code

10. Unresolved External error when linking a Fortran Dll from C++

11. Linking FORTRAN Routine to C++ Program, MS C++ DVF Library Problem

12. Linking asm code to C++ code

 

 
Powered by phpBB® Forum Software