C++11 headers missing on Mac OS X 10.8.2 (MountainLion) - macos

I'm new to Mac. I have some Linux and Windows C++11 source which uses Boost I'd like to build on this Mac. Installed MacPort (should I instead be using Homebrew?) then successfully ran commands such as:
sudo port install cmake
sudo port install boost
sudo port install openssl
sudo port install gcc49
sudo port install gcc_select
sudo port install --set gcc mp-gcc49
CMake correctly finds Boost 1.57.0 and sets up the makefile. But when I run make, it seems it cannot find normal C++11 headers such as "chrono":
In file included from ../src/test.cpp:10:
../src/test_private.hpp:33:10: fatal error: 'chrono' file not found
#include <chrono>
^
1 error generated.
Indeed, when I go looking for the C++ header files, I see some of them in /usr/include/c++/4.2.1/ but newer files such as chrono and thread are missing.
Is there another package I need to install before I can compile C++11 source code on a Mac?

Xcode, the Apple supplied compiler/tools, comes with two implementations of the std::lib:
gcc's libstdc++, version 4.2.
libc++
The first is very, very old, and does not support anything in C++11 such as <chrono>. The second supports C++11 quite well, but can only be used with clang, not gcc. clang comes with Xcode.
You will also need to install command line tools after you install Xcode:
xcode-select --install

Related

Can not find LLVM library files

I have been trying to set up llvm on my linux. I am running fedora. I have tried installing llvm through dnf install llvm and it appears to be installed on my computer. However, in my c++ code any header I try to include from it shows error. I am currently trying to do it manually but if you have any answers I would be grateful if you share it with me. Thanks.
You can use the following commands to find where are the include directory and LLVM libraries in your Linux system. Then they can be included into your compilation command.
llvm-config --includedir
llvm-config --libfiles
I don't use Fedora, but in my Linux Mint 20, these commands return:
/usr/lib/llvm-10/include
/usr/lib/llvm-10/lib/libLLVM-10.so

Run or use GCC without install

Can I use GCC for e.g GCC4.0.3 without installation
In my macOS I have installed Clang xcode , and GCC from Homebrew
In my Linux they are installed as well
But I want to use GCC (Specially older version) besides most updated version
Like NVM that manage Node version and it lets you install many nodejs with different version on your system
I want to use GCC4 specially for science and compiling Old FORTRAN to make my Source codes run and see the results
In new OS both macOS and Linux when you install gcc it will install most updated and that is not useful for old fortran or old codes.
So In my solution i think its better to use gcc without install or even install gcc to custom directory folder and copy the codes in that directory and compile them but not to install as wide system and make incompatibility with default GCC and CLANG on system
Thanks in advance

Install GCC 5.X on Xcode 6

I need to use/integrate GCC 5.X (in my case 5.3, and it is already installed) on Xcode 6.2.
I've found a lot of outdated tutorials about GCC 4.X and Xcode 5 (or lower), but all of them are outdated and do not work anymore.
I've also found this tutorial, but I have not the 5.3.xcplugin file that the tuto recommend to copy.
I am still on Mac OS X Maverick, and I can install Xcode 7 if necessary.
Anybody would know how to do it?
MacPorts still has an installer for Mavericks. It will likely add /opt/local/bin:/opt/local/sbin to your $PATH in .profile, or whatever shell startup file you use, and leave a backup of the old file you can probably get rid of once you're satisfied.
I would suggest upgrading to the latest Xcode release - and to El Capitan unless you have some specific reason not to. AFAIK, if you can run Mavericks, you can run the latter. I will avoid any arguments about the merits of Brew vs. MacPorts here. There's plenty of documentation on the MacPorts pages.
Make sure the package database is up to date:
sudo port -v selfupdate`
Have a look at the existing gcc ports:
port list | grep gcc
note: you might as well install the stable gcc6 (6.1.0) package.
Install the package - this may also install dependency packages:
sudo port install gcc6 [-universal]
This may take a while, as it might need to build from source. For most packages, the -universal flag says that you don't care about 32-bit (IA32) builds, etc.
You can see various package versions with port select ... options, e.g.,
port select --list gcc
And enable the installed gcc:
sudo port select --set gcc mp-gcc6
You may need to rehash so the shell adds the new binaries to its search. Or just start a new shell. gcc -v should yield something like:
gcc version 6.1.0 (MacPorts gcc6 6.1.0_0)

GCC installed but not showing on OSX 10.9.5

I had a working gcc/g++(2 month back;can't remember) from terminal of my mavericks with Xcode & Command Line Tools 6.0.1(6A317) but its not working now(might be due to minor OS upgrade). I tried all the commands gcc, g++, clang but neither of them works. Again, I tried installing using MacPorts using sudo port install gcc49 and it completed successfully but still any of the commands doesn't works(even after restarting terminal).
Additional Information- When I look for gcc/g++ in /usr/bin/, there is only alias present.
But clang++ and clang are present in /usr/bin/.

Set default GCC to Fink-installed GCC 4.5?

I've got GCC 4.2 that came with my installation of Mac OS X 10.6.4, plus GCC 4.5 installed via Fink. I wanted to use gcc_select to change the default compiler to GCC 4.5, but was told gcc_select does not exist.
Is there another way to set the default compiler? Or do I need to do so manually? If so, how?
Thanks!!
I used MacPorts to install my GCC 4.4, and also told MacPorts to download gcc_select:
sudo port install gcc_select
then I typed
gcc_select -l
to list the available versions. Then
gcc_select mp-gcc44
to switch. I haven't used Fink but hopefully you can install gcc_select from there :)

Resources