Re: Accessing C++ function with Mixed Upper/Lower case name from F90 subroutine

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi Glenn,
On Tue, Mar 30, 2010 at 11:15:27AM -0400, Glenn H Sembroski wrote:
>   I have a problem trying to prepare a large simulation package, using  
> mixed F90 and C++ routines, to compile and build under GCC (g++, and  
> gfortran).  The problem is I have a C++ function: Gauss() which is  
> called from an F90 routine:
>   x=gauss()
>
> This package was made able to  build under the Intel fortran compiler by  
> adding to the fortran file the Intel compile directive:
>
> !DEC$ ATTRIBUTES ALIAS:'Gauss' :: gauss
>
> I attempted to build this program using GCC  where for F90 code the  
> gfortran compiler option -fno-underscoring was used.
>
> Presently my fortran routine won't build. It gets the error:
>
> 485: undefined reference to `gauss'
>
> So, my question is, is there a way in GCC to enable the linker to find  
> the C++  'Gauss' method?

Well, just a possibility: C++-functions are something special (due to
the possibility that they can be overloaded e.g.), you can't call them
directly from C or F77 - and I think F90 might have the same problem: A
C++-Function "Gauss" will NOT be called "gauss" for linking - but
instead it will have a much longer name depending on its parameters...

You have to mark the C++-function as e.g. extern "C" void Gauss(); in
order to be able to call it from C or F77 (and probably also for calls
from F90?)

Axel

[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux