Error Compiling with gcc 4.7 -std=c++11

234 views
Skip to first unread message

Cristian Zambrano

unread,
Dec 26, 2013, 3:26:41 PM12/26/13
to biopp-de...@googlegroups.com
Saludos

I'm compiling with gcc 4.7 and -std=c++11 flag, and I have this error

OptimizationTools.h:87:54: error: call of overloaded ‘isnan(double)’ is ambiguous


Compiling src/problems/Phylogeny.cpp
 g++47 -O3 -std=c++11  -I src/core/. -I src/encodings/. -I src/encodings/variable/. -I src/encodings/solutionType/. -I src/experiments/. -I src/experiments/main/. -I src/experiments/settings/. -I src/experiments/util/. -I src/main/. -I src/metaheuristics/. -I src/metaheuristics/paes/. -I src/metaheuristics/cmaes/. -I src/metaheuristics/cmaes/utils/. -I src/metaheuristics/moead/. -I src/metaheuristics/smpso/. -I src/metaheuristics/pso/. -I src/metaheuristics/ssGA/. -I src/metaheuristics/gde3/. -I src/metaheuristics/gGA/. -I src/metaheuristics/smsemoa/. -I src/metaheuristics/de/. -I src/metaheuristics/nsgaII/. -I src/operators/. -I src/operators/mutation/. -I src/operators/selection/. -I src/operators/crossover/. -I src/problems/. -I src/qualityIndicator/. -I src/qualityIndicator/main/. -I src/qualityIndicator/util/. -I src/util/. -I src/util/archive/. -I src/util/comparators/. -I src/util/wrapper/. -lbpp-core -lbpp-seq -lbpp-phyl -c -o build/problems/Phylogeny.o src/problems/Phylogeny.cpp
In file included from /home/cristian/Bpp/include/Bpp/Phyl/Likelihood/DRTreeLikelihood.h:43:0,
                 from /home/cristian/Bpp/include/Bpp/Phyl/Likelihood/DRHomogeneousTreeLikelihood.h:44,
                 from /home/cristian/Bpp/include/Bpp/Phyl/Likelihood/NNIHomogeneousTreeLikelihood.h:43,
                 from /home/cristian/Bpp/include/Bpp/Phyl/OptimizationTools.h:44,
                 from src/problems/./Phylogeny.h:51,
                 from src/problems/Phylogeny.cpp:21:
/home/cristian/Bpp/include/Bpp/Phyl/Likelihood/AbstractNonHomogeneousTreeLikelihood.h:127:31: warning: ‘auto_ptr’ is deprecated (declared at /usr/lib/gcc/i686-redhat-linux4.7.0/4.7.0/../../../../include/c++/4.7.0/backward/auto_ptr.h:87) [-Wdeprecated-declarations]
In file included from src/problems/./Phylogeny.h:51:0,
                 from src/problems/Phylogeny.cpp:21:
/home/cristian/Bpp/include/Bpp/Phyl/OptimizationTools.h: In member function ‘virtual void bpp::NaNListener::optimizationStepPerformed(const bpp::OptimizationEvent&)’:
/home/cristian/Bpp/include/Bpp/Phyl/OptimizationTools.h:87:54: error: call of overloaded ‘isnan(double)’ is ambiguous
/home/cristian/Bpp/include/Bpp/Phyl/OptimizationTools.h:87:54: note: candidates are:
In file included from /usr/include/math.h:71:0,
                 from /usr/lib/gcc/i686-redhat-linux4.7.0/4.7.0/../../../../include/c++/4.7.0/cmath:46,
                 from /usr/lib/gcc/i686-redhat-linux4.7.0/4.7.0/../../../../include/c++/4.7.0/random:38,
                 from /usr/lib/gcc/i686-redhat-linux4.7.0/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:67,
                 from /usr/lib/gcc/i686-redhat-linux4.7.0/4.7.0/../../../../include/c++/4.7.0/algorithm:63,
                 from /home/cristian/Bpp/include/Bpp/Phyl/Node.h:55,
                 from /home/cristian/Bpp/include/Bpp/Phyl/TreeTools.h:44,
                 from /home/cristian/Bpp/include/Bpp/Phyl/TreeTemplateTools.h:45,
                 from /home/cristian/Bpp/include/Bpp/Phyl/TreeTemplate.h:45,
                 from src/encodings/variable/./PhyloTree.h:33,
                 from src/encodings/solutionType/./PhyloTreeSolutionType.h:25,
                 from src/problems/./Phylogeny.h:26,
                 from src/problems/Phylogeny.cpp:21:
/usr/include/bits/mathcalls.h:235:1: note: int isnan(double)
In file included from /usr/lib/gcc/i686-redhat-linux4.7.0/4.7.0/../../../../include/c++/4.7.0/random:38:0,
                 from /usr/lib/gcc/i686-redhat-linux4.7.0/4.7.0/../../../../include/c++/4.7.0/bits/stl_algo.h:67,
                 from /usr/lib/gcc/i686-redhat-linux4.7.0/4.7.0/../../../../include/c++/4.7.0/algorithm:63,
                 from /home/cristian/Bpp/include/Bpp/Phyl/Node.h:55,
                 from /home/cristian/Bpp/include/Bpp/Phyl/TreeTools.h:44,
                 from /home/cristian/Bpp/include/Bpp/Phyl/TreeTemplateTools.h:45,
                 from /home/cristian/Bpp/include/Bpp/Phyl/TreeTemplate.h:45,
                 from src/encodings/variable/./PhyloTree.h:33,
                 from src/encodings/solutionType/./PhyloTreeSolutionType.h:25,
                 from src/problems/./Phylogeny.h:26,
                 from src/problems/Phylogeny.cpp:21:
/usr/lib/gcc/i686-redhat-linux4.7.0/4.7.0/../../../../include/c++/4.7.0/cmath:629:3: note: constexpr bool std::isnan(long double)
/usr/lib/gcc/i686-redhat-linux4.7.0/4.7.0/../../../../include/c++/4.7.0/cmath:625:3: note: constexpr bool std::isnan(double)
/usr/lib/gcc/i686-redhat-linux4.7.0/4.7.0/../../../../include/c++/4.7.0/cmath:621:3: note: constexpr bool std::isnan(float)


Can anyone help me???

Thanx a lot

Ikram

unread,
Feb 8, 2014, 10:00:54 AM2/8/14
to biopp-de...@googlegroups.com
I am getting the exact same error when I try to compile the ALE program (https://github.com/ssolo/ALE) which uses Bio++ libraries.
Any guru who has been able to solve it?

Julien Yann Dutheil

unread,
Feb 8, 2014, 11:46:43 AM2/8/14
to biopp-de...@googlegroups.com
Hi,

This is not exactly a "problem"... Bio++ simply does not compile with c++11 :(
I am convinced that one day we will port the code to the new C++ standard, but currently much more people use the previous norm, so the upgrade is not scheduled for now.
Yet in this case the problem seems to be related to the isnan function, so I will try to see if I can find a trick, but I cannot warranty that we will be able to solve all issues related to compiling with c++11 :s

J.


--
You received this message because you are subscribed to the Google Groups "Bio++ Development Forum" group.
To unsubscribe from this group and stop receiving emails from it, send an email to biopp-devel-fo...@googlegroups.com.
To post to this group, send email to biopp-de...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/biopp-devel-forum/6ed5bf5a-08fb-4c68-8b37-ebecf856cb5b%40googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.



--
Julien Y. Dutheil, Ph-D
0 (+49) 6421 178 986

§ Max Planck Institute for Terrestrial Microbiology
Department of Organismic Interactions
Marburg -- GERMANY

§ Intitute of Evolutionary Sciences - Montpellier
University of Montpellier 2 -- FRANCE

Ikram

unread,
Feb 9, 2014, 1:21:15 PM2/9/14
to biopp-de...@googlegroups.com
You are right, because I tried Bio++ previously with PHYLDOG and it was working fine. The newer application that I am trying (ALE) requires C++11 which seems to be the bottleneck. I will also try to explicitly cast the indicated code snippets to double/float and see if that works. Will update you on that.

Thanks for your time :=)
Ikram

Julien Yann Dutheil

unread,
Feb 10, 2014, 2:55:30 AM2/10/14
to biopp-de...@googlegroups.com
There indeed seems to be a incompatibility between isnan from math.h and the new isnan function of c++11 :s Please tell me if casting solves the issue.

Best,

J.



For more options, visit https://groups.google.com/groups/opt_out.

Ikram

unread,
Feb 28, 2014, 8:05:07 AM2/28/14
to biopp-de...@googlegroups.com
I searched stackoverflow forums and someone explained that isnan() (and the likes like abs() etc) are defined both in C (<math.h>) and C++ (<cmath>) libs. I thought that C++11 might have some complex relationship with existing C libs and tried changing the isnan() to std::isnan() and that did the trick :)

BR,
Ikram

Ikram

unread,
Feb 28, 2014, 8:06:23 AM2/28/14
to biopp-de...@googlegroups.com

Julien Yann Dutheil

unread,
Mar 6, 2014, 2:47:38 PM3/6/14
to biopp-de...@googlegroups.com
Dear Ikram,

Well done, and thanks a lot! Indeed there should be a std:: here, this was clearly an error!
I fix this.

Many thanks for solving this issue.

All the best,

Julien.


On Friday, February 28, 2014 2:05:07 PM UTC+1, Ikram wrote:
Reply all
Reply to author
Forward
0 new messages