I installed gcc49 on FreeBSD10.1. I am trying to use it for C++11 development. However, every time I'm compiling some C++11 valid code (yes I use -std=c++11
) that uses specific math functions, it spits out errors, such as
error: std::round is not a member of std
/usr/include/math.h
For example, here:
#include <cmath>
#include <iostream>
int main()
{
std::cout << std::round(10.1) << std::endl;
}
So it seems it tries to use the old include files that came with FreeBSD, and not the ones corresponding to the new gcc
from /usr/local/lib/gcc49/include
I tried setting CPLUS_INCLUDE_PATH
to /usr/local/lib/gcc49/include
with no luck, the system still tries to search /usr/include
instead.
I saw that this may be a bug in FreeBSD g++,
Getting GCC in C++11 mode to work on FreeBSD
however even using the -D_GLIBCXX_USE_C99
as suggested in https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=194929
doesn't fix the problem for math functions.
The weirdest thing is that I can compile any other C++11 functions not from <cmath>
, like std::stol
, but have to use the -D_GLIBCXX_USE_C99
flag as mentioned in the bug report above.
Any idea how to make g++ fully functional with C++11 on FreeBSD 10.1?