0

I am trying to make g_elpot (https://jugit.fz-juelich.de/computational-neurophysiology/g_elpot) and got the following error:

g++ -O3 -Wno-unused -funroll-all-loops -std=c++11 -fopenmp -I/usr/local/gromacs/include -I/usr/local/fftw/include   -c -o dx.o dx.cpp
dx.cpp: In function ‘void write_dx_file(real*, real*, int*, real (*)[3], const char*, unit_t)’:
dx.cpp:41:33: error: ‘isnan’ was not declared in this scope
         if (isnan(grid_values[i]))
                                 ^
dx.cpp:41:33: note: suggested alternative:
In file included from /usr/local/gromacs/include/gromacs/math/vectypes.h:40:0,
                 from dx.h:3,
                 from dx.cpp:1:
/usr/include/c++/5/cmath:641:5: note:   ‘std::isnan’
     isnan(_Tp __x)
     ^
<builtin>: recipe for target 'dx.o' failed
make: *** [dx.o] Error 1

I am using g++ (Ubuntu 5.4.0-6ubuntu1~16.04.12) 5.4.0 20160609 and cmake version 3.14.0.

My Makefile is:

# Generated automatically from Makefile.in by configure.
#
# This is a Gromacs 3.0 template makefile for your own utility programs.
#
# Copy this file to whatever directory you are using for your own
# software and add more targets like the template one below.
#
# If you are using gmake it is relatively straightforward to add
# an include based on environment variables (like previous Gromacs versions)
# to select compiler flags and stuff automatically, but below it is static:
#

# Variables set by the configuration script:
LIBS         = -lgromacs -lfftw3f -lm -fopenmp
LDFLAGS      = -L/usr/local/gromacs/lib -L/usr/local/fftw/lib
CPPFLAGS     = -I/usr/local/gromacs/include -I/usr/local/fftw/include 
CXXFLAGS     = -O3 -Wno-unused -funroll-all-loops -std=c++11 -fopenmp
CXX          = g++
LD           = $(CXX)

g_elpot: g_elpot.o elmap_grid.o spline_interpolation.o fitting.o dx.o spme_grid.o convergence_check.o frame.o result.o units.o molecule.o memory_check.o debug.o
        $(LD) $(LDFLAGS) -o $@ $^ $(LIBS)

I was trying to run g_elpot and wanted to install it and ran into this issue while running make

Tsyvarev
  • 60,011
  • 17
  • 110
  • 153
AKA
  • 13
  • 4
  • the error is pretty clear and even gives you a fix, you need to include `cmath` in `dx.cpp` – Alan Birtles Dec 03 '22 at 08:42
  • Okay. I am new and dont know anything regarding this. So I can just add #include to fix this? – AKA Dec 03 '22 at 08:53
  • Related: https://stackoverflow.com/questions/39130040/cmath-hides-isnan-in-math-h-in-c14-c11. It seems that `#include ` hides `isnan` if compiled with C++11 standard or newer. You build with `-std=c++11`, so the function should be accessed as `std::isnan`. – Tsyvarev Dec 03 '22 at 09:49
  • So. I have to build it using c++11? – AKA Dec 03 '22 at 10:24
  • The thing is, they provide the make file directly from their gitlab link – AKA Dec 03 '22 at 10:25

0 Answers0