How do I get a working GCC-based C++11 setup on FreeBSD 10? It seems that the standard library that comes with recent GCC versions on FreeBSD is broken. I've installed the port gcc49 and then try to compile this: #include <string> int main() { auto str = std::to_string(42); str = std::to_string(42ull); str = std::to_string(4.2); str.clear(); return 0; } This gives me an error: g++49 -v -std=c++11 foo.cc Using built-in specs. COLLECT_GCC=g++49 COLLECT_LTO_WRAPPER=/usr/local/libexec/gcc49/gcc/x86_64-portbld-freebsd10.0/4.9.2/lto-wrapper Target: x86_64-portbld-freebsd10.0 Configured with: ./../gcc-4.9-20141022/configure --disable-nls --enable-gnu-indirect-function --libdir=/usr/local/lib/gcc49 --libexecdir=/usr/local/libexec/gcc49 --program-suffix=49 --with-as=/usr/local/bin/as --with-gmp=/usr/local --with-gxx-include-dir=/usr/local/lib/gc c49/include/c++/ --with-ld=/usr/local/bin/ld --with-pkgversion='FreeBSD Ports Collection' --with-system-zlib --with-ecj-jar=/usr/local/share/java/ecj-4.5.jar --enable-languages=c,c++,objc,fortran,java --prefix=/usr/local --mandir=/usr/local/man --infodir=/usr/local/info/gcc49 --build=x86_64-portbld-freebsd10.0 Thread model: posix gcc version 4.9.2 20141022 (prerelease) (FreeBSD Ports Collection) COLLECT_GCC_OPTIONS='-v' '-std=c++11' '-shared-libgcc' '-mtune=generic' '-march=x86-64' /usr/local/libexec/gcc49/gcc/x86_64-portbld-freebsd10.0/4.9.2/cc1plus -quiet -v foo.cc -quiet -dumpbase foo.cc -mtune=generic -march=x86-64 -auxbase foo -std=c++11 -version -o /tmp//ccbNFhtI.s GNU C++ (FreeBSD Ports Collection) version 4.9.2 20141022 (prerelease) (x86_64-portbld-freebsd10.0) compiled by GNU C version 4.9.2 20141022 (prerelease), GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 ignoring nonexistent directory "/usr/local/lib/gcc49/gcc/x86_64-portbld-freebsd10.0/4.9.2/../../../../../x86_64-portbld-freebsd10.0/include" #include "..." search starts here: #include <...> search starts here: /usr/local/lib/gcc49/include/c++/ /usr/local/lib/gcc49/include/c++//x86_64-portbld-freebsd10.0 /usr/local/lib/gcc49/include/c++//backward /usr/local/lib/gcc49/gcc/x86_64-portbld-freebsd10.0/4.9.2/include /usr/local/include /usr/local/lib/gcc49/gcc/x86_64-portbld-freebsd10.0/4.9.2/include-fixed /usr/include End of search list. GNU C++ (FreeBSD Ports Collection) version 4.9.2 20141022 (prerelease) (x86_64-portbld-freebsd10.0) compiled by GNU C version 4.9.2 20141022 (prerelease), GMP version 5.1.3, MPFR version 3.1.2, MPC version 1.0.2 GGC heuristics: --param ggc-min-expand=100 --param ggc-min-heapsize=131072 Compiler executable checksum: 8405316ee381c37148f55a17e42da47a foo.cc: In function 'int main()': foo.cc:5:14: error: 'to_string' is not a member of 'std' auto str = std::to_string(42); ^ foo.cc:6:9: error: 'to_string' is not a member of 'std' str = std::to_string(42ull); ^ foo.cc:7:9: error: 'to_string' is not a member of 'std' str = std::to_string(4.2); ^ The default include search path is /usr/local/lib/gcc49/include/c++/, which does contain the <string> header. Makes sense, because the gcc49 port ships with a corresponding libstc++. But it seems broken, per the above error. (Note: I'm aware that Clang is the default compiler on FreeBSD 10. But in this case I'm specifically looking to support a GCC-based toolchain.)
This isn't a help forum, but I'll assign the PR to gerald@ and let him decide if there's a problem with gcc or not. (I suspect not but it's not my call)
(In reply to John Marino from comment #1) > This isn't a help forum It's a bug report, to be clear. (Admittedly, my initial question may not suggest it directly.) This bug is related to #193528. Adding -D_GLIBCXX_USE_C99 to the invocation fixes this particular issue on 10.0 and 10.1. *** This bug has been marked as a duplicate of bug 193528 ***