# Problems with g++5.4 which do not happen on Ubuntu



## c_geier (Jul 27, 2017)

When trying to compile the following C++ snippet with gcc 5.4 without any flags I get an error (as expected).


```
#include <string>
#include <iostream>

int main(){
  std::cout << std::to_string(0) << "\n";
  return 0;
}
```

error:

```
$ g++-5 test.cpp
test.cpp: In function ‘int main()’:
test.cpp:6:18: error: ‘to_string’ is not a member of ‘std’
```


When I use the `-std=c++14` flag on Ubuntu 16.04.2 LTS it compiles and runs fine. Even with the flag I get the same error as before on FreeBSD, even with what is supposed to be the same version of gcc:


```
$ g++5 --version
g++5 (FreeBSD Ports Collection) 5.4.0
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

$ g++5 -std=c++14 test.cpp                                                                                                        test.cpp: In function 'int main()':
test.cpp:6:18: error: 'to_string' is not a member of 'std'
     std::cout << std::to_string(0) << "\n";
```

On Ubuntu:

```
% g++-5 --version
g++-5 (Ubuntu 5.4.0-6ubuntu1~16.04.4) 5.4.0 20160609
Copyright (C) 2015 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
```

Does anyone have an explanation for this different behavour and a suggestion on how I can get this to run? (This is just a minimal example of trying to get https://github.com/clangen/musikcube to compile on FreeBSD.)


----------



## SirDice (Jul 28, 2017)

Not much of a programmer and I certain have no experience with GCC 5.4 but you typically need to supply -I/usr/local/include and -L/usr/local/lib on FreeBSD. I'm not sure if those are the correct directories because you can install different versions of GCC next to each other. If you don't supply a path for includes and libraries GCC only looks in /usr/{include,lib}.


----------



## acheron (Jul 28, 2017)

See the end of this post: https://stackoverflow.com/questions/26095886/error-to-string-is-not-a-member-of-std


----------



## tobik@ (Jul 28, 2017)

c_geier said:


> Does anyone have an explanation for this different behavour and a suggestion on how I can get this to run?


It works with lang/gcc6, so maybe that is an alternative.  Musikcube's build docs don't mention requiring GCC.  Are you sure it can't be compiled with Clang?


----------

