fortran and C++ and isfinite()

Hi folks,
A user here is having issue linking their code and Im unable to figure out why.
Its a fortran and c++ code with MPI. Using pgc++ to compile all the cpp files into a library which is then used with the fortran source. Compiling and linking the fortran is done with the mpi wrapper compile scripts which use pgf90 as the base compiler.
The c++ routine is trying to use the isfinite() function but at link time I get complaints like
In function std::isfinite(double)': ..../pgi/17.1/linux86-64/17.1/include-gcc48/cmath:667: undefined reference to _pgi_isfinitedd’

there is some difference depending on which gcc library is available at compile time and which gcc library was available at PGI compiler install time.
ie sometimes it gets a complaint about isfinite() from the gnu header files but always about the same function.

this has also been tried with gnu 4.9+ and pgi 17.5 and get the same sort of complaints about isfinite()

thoughts/suggestions?

thanks
steve

Two ways to handle this. Use the linux isfinite(x) or use IEEE version

program isfinite_test
! USE IEEE_ARITHMETIC
real*8 a,b
integer i,j
a=1234567.0D0
! i=IEEE_IS_FINITE(a)
i=isfinite(a)
! print *,“a=1234567.0 IEEE_IS_FINITE(a)=”,i
print *,“a=1234567.0 isfinite(a)=”,i
end


But you need an interface from the Fortran to C

#include <math.h>
int isfinite_(double x) { return (isfinite(x));}



program isfinite_ieee_test
USE IEEE_ARITHMETIC
real*8 a,b
integer i,j
a=1234567.0D0
i=IEEE_IS_FINITE(a)
! i=isfinite(a)
print *,“a=1234567.0 IEEE_IS_FINITE(a)=”,i
! print *,“a=1234567.0 isfinite(a)=”,i
end

pgfortran isfinite_test.f90 isf.c -o isf_no_ieee

pgfortran isinfinite_ieee_test.f90 -o isf_ieee

dave

the library Im using is c++ code and compiled with pgc++.

steve

The solution is to link the objects including the C++ objects using pgfortran, and make sure any C++ runtime utils are linked as well,
using the pgfortran link switch

pgc++libs

to link the correct PGI C++ libs, in the correct order, in pgfortran.

It may also be necessary to create a wrapper program so that
isfinite_() is mapped to call the isfinite() routine.

dave