Compiling with PGF95 - calling a function from c++ library

I am compiling a g77 source code with the Protland Group’s Fortran 95. Everything seems to be ok until a C++ function is called from a fortran routine. I get an “undefined reference” error message. I suspect that it has something to do with the fact that the C++ function is in an archived library.

The C++routines are added to a library (libtest.a). This is done by compiling with the -c option and then placing the object files an archive (ar rl ./libtest.a *.o) .

The compilation goes smoothly when I use g77.

Are there any special considerations (compiler switches) during compilation for the call of c++ functions from fortran routines (as explained above).

Thanks

Hi EigenG,

My best guess is that your C++ code has appended the function names with two underscores, which is what g77 expects, instead of a single underscore, which is what pgf95 expects. If you change these names to use a single underscore, does this solve the linking issues?

Chapter 10 of the PGI User’s guide gives a more information about inter-language calling as well as examples of Fortran calling C++.

Hope this helps,
Mat

Thanks Mat, your suggestion resolved my problem.