Project

General

Profile

Error while compiling cdo-1.9.2 on Ubuntu 16.04.3 lts

Added by Amithabh Shrinivas over 6 years ago

I just upgraded from ubuntu 14.04.5 to 16.04.3. While working on Ubuntu 14.04, I never had issues compiling cdo. But when I tried compiling on 16.04 I get the following error:

compare.h:35:37: error: ‘isnan’ was not declared in this scope # define DBL_IS_NAN(x) (isnan(x))
^
compare.h:46:30: note: in expansion of macro ‘DBL_IS_NAN’ # define DBL_IS_EQUAL(x,y) (DBL_IS_NAN(x)||DBL_IS_NAN(y)?(DBL_IS_NAN(x)&&DBL_IS_NAN(y)?1:0):!(x < y || y < x))
^
Fillmiss.cc:529:22: note: in expansion of macro ‘DBL_IS_EQUAL’
if ( DBL_IS_EQUAL(field2.ptr[i], field2.missval) ) nmiss++;
^
compare.h:35:37: note: suggested alternative: # define DBL_IS_NAN(x) (isnan(x))
^
compare.h:46:30: note: in expansion of macro ‘DBL_IS_NAN’ # define DBL_IS_EQUAL(x,y) (DBL_IS_NAN(x)||DBL_IS_NAN(y)?(DBL_IS_NAN(x)&&DBL_IS_NAN(y)?1:0):!(x < y || y < x))
^
Fillmiss.cc:529:22: note: in expansion of macro ‘DBL_IS_EQUAL’
if ( DBL_IS_EQUAL(field2.ptr[i], field2.missval) ) nmiss++;
^
In file included from /usr/include/c++/5/random:38:0,
from /usr/include/c++/5/bits/stl_algo.h:66,
from /usr/include/c++/5/algorithm:62,
from nanoflann.hpp:53,
from grid_search.h:7,
from Fillmiss.cc:30:
/usr/include/c++/5/cmath:641:5: note: ‘std::isnan’
isnan(_Tp __x)
^
Makefile:2760: recipe for target 'cdo-Fillmiss.o' failed
make2: * [cdo-Fillmiss.o] Error 1
make2: Leaving directory '/home/kcube/CDO/cdo-1.9.2/src'
Makefile:719: recipe for target 'all' failed
make1:
[all] Error 2
make1: Leaving directory '/home/kcube/CDO/cdo-1.9.2/src'
Makefile:457: recipe for target 'all-recursive' failed
make: *
* [all-recursive] Error 1

Looks like the C++ compiler is the responsible for this error. Can someone please help fix this issue? Thanks.

Amithabh


Replies (4)

RE: Error while compiling cdo-1.9.2 on Ubuntu 16.04.3 lts - Added by Ljiljana Dekic over 6 years ago

Hi,
I've tried with some advices regarding Ubuntu and it was successful.
You have to change

#include <math.h>
to
#include <cmath>

and
isnan
to
std::isnan

in several files
src/compare.h
src/array.cc
src/expr.cc
src/Ensval.cc

Good luck!

RE: Error while compiling cdo-1.9.2 on Ubuntu 16.04.3 lts - Added by Matthew Forrest over 6 years ago

Hi Ljiljana and Amithabh,

I just hit upon exactly the same problem. But your fix didn't work Ljiliana. Are there more source files that need to be altered rather than just those four? I notice that the strings "isnan" and "include <math.h>" crop up in more places in the source code...

Cheers,

Matt

RE: Error while compiling cdo-1.9.2 on Ubuntu 16.04.3 lts - Added by Ljiljana Dekic over 6 years ago

Hi Matt,
these changes were sufficient for me.
I suggest you to start with make, hunt for errors and maybe change step by step,
that is the way I did.
Regards.
Ljiljana

RE: Error while compiling cdo-1.9.2 on Ubuntu 16.04.3 lts - Added by Matthew Forrest over 6 years ago

I tried again, this time making the changes more carefully and methodically and it worked out :) Thanks Ljiljana!

    (1-4/4)