Using Homebrew to install GCC-built boost libraries on Mac OS X - c++

Is it possible to use Homebrew to install boost libraries compiled with GCC (instead of Clang)?
I have tried pointing HOMEBREW_CXX to my Homebrew version of GCC, but it doesn't seem to do the trick.
If not, I can always modify the configure file following the suggestion in this answer:
How to install Boost with specified compiler (say GCC)

brew install boost --cc=gcc-4.9 will do it. install --cc is described in man brew.

Related

Install Boost with GCC on MacOS [duplicate]

I've installed gcc-4.6 using the homebrew-alternatives gcc formula, but I can't seem to get it to use that GCC to install other formulas. Specifically Open-MPI and boost.
Does anyone know how to make Homebrew use this new compiler?
Thanks!
It looks like the latest versions of Homebrew now support the HOMEBREW_CC and HOMEBREW_CXX environment variables.
So now you can do the following:
$ HOMEBREW_CC=gcc-4.2 HOMEBREW_CXX=g++-4.2 brew install ice
Homebrew can't adapt to other versions of gcc using command line options. You can easily override the older compiler, though, if you edit the open-mpi and boost formula. For example, you can add a few commands after the "def install" in open-mpi.rb:
def install
# Force compilation with gcc-4.6
ENV['CC'] = '/usr/local/bin/gcc-4.6'
ENV['LD'] = '/usr/local/bin/gcc-4.6'
ENV['CXX'] = '/usr/local/bin/g++-4.6'
# Compiler complains about link compatibility with FORTRAN otherwise
ENV.delete('CFLAGS')
ENV.delete('CXXFLAGS')
That worked for me on Lion. Good luck.
These answers are all fairly old now. It seems that recent versions of homebrew have a '--cc' option that enables you to select the c compiler to use. For example
brew install --cc=gcc-6 <package-name>
will install using the brew version of gcc
From their wiki it sounds like they don't support other compilers:
Installing a custom version of GCC or autotools into the $PATH has the potential to break lots of compiles. So we stick to the Apple-provided compilers.

Can't find shared libraries in Boost (Linux Mint)

I just switched to using Linux Mint and I'm having trouble figuring out the way the default Boost package works on this system. Normally I'd just install a package called boost, and locate my way to the shared libraries, but on Linux Mint none of that seems to work.
I've done apt-get install libboost-all-dev, but I absolutely can't find any of Boost's .so files. Did I install the right package? If so, where are they? I'm especially in need of libboost_locale.so.
Thanks!
Usually, you can find them in /usr/lib (like here https://askubuntu.com/questions/263461/where-is-my-boost-lib-file). You can also try
apt-cache show libboost-all-dev

Does Linux command libboost-all-dev install and compile the header-only libraries?

On Ubuntu there is a command to install boost libraries which is something like this:
sudo apt-get install libboost-all-dev
does this command also install and compile the header-only libraries?
If not, what other terminal command would I need to execute so that I can install the FULL set of boost libraries?
My ultimate aim is to know which linux terminal commands I need to install (and have available) to obtain all of the boost libraries.
As is implied by "header only", one does not need to compile the header-only libraries. They're just headers.
Now, the libbost-all-dev package does install those libraries which need compilation (in addition to the header-only libs), but it does not compile them on the spot. Ubuntu is a so-called binary distribution, which means that it distributes packages in compiled form. Apt downloads the binaries and installs them immediately. This is in contrast to e.g. Gentoo which is a source distribution (and compiles everything on your machine).
In short, no further commands are necessary. Installing libbost-all-dev will install all available Boost libraries on Ubuntu.
Your questions, as posed, makes no sense.
The Debian / Ubuntu package libboost-all-dev has dependencies, and those dependencies do include the few binary library packages (eg Boost Thread, the formatting parts of Boost DateTime, etc pp). All those will get installed.
And yes, the intent of this meta package is to install the rest of the Boost development environment.
But it does not compile anything. All Debian / Ubuntu packages are pre-generated and built-offline and "just installed" at your end.
You can inspect the content of a package by browsing the online database.
But if you are only interested in header-only libraries I suggest to download the latest version of the boost libraries right from the official website; you should also learn how to build boost from the source because it's a know-how that you are very likely to use in a near future if you are relying on that library.
An equivalent step to browsing the online database, it's about using the following command
apt-cache show <package>
so, in your case
apt-cache show libboost-all-dev
and this will give you a very specific idea about what you are about to install.

what is the default location for boost library when installed using macport on mac ?

I just now installed boost on mac, using macport with following command
sudo port install boost
It's installed fine, but I have no idea where the boost library got installed to.
Where should it be / how could I search for it?
The headers should be in /usr/local/include/boost and the libs should be in /usr/local/lib. Or in /opt/local/include/boost and /opt/local/lib, I believe.
You can search using locate:
locate boost
Using the macOS Sierra 10.13.5, installed boost with brew. location in /usr/local/include/
For me, with High Sierra and MacPorts 2.4.4, MacPorts installed Boost 1.66 under:
/opt/local/include/boost
Default is /usr/local/lib /usr/local/include
You might want to rebuild the libs using the clang toolchain
./bjam toolset=clang
and then do a manual install in a specific location especially if you want to switch between versions (for source control or testing etc)
> find . -name boost
also works

how do i build gcc on a mac?

I'd like to build the latest version of gcc on a mac. I have the latest xcode but I'm looking for some of the c++0x features that are in more recent versions (the lambda functions, etc).
Are there any good step-by-step tutorials on doing this?
You should look at the Homebrew project.
Homebrew allows you to do things like this:
brew install gcc
Mac homebrew installation instructions are available here.
Add GCC support to a fresh Xcode 4.2 installation using this homebrew formula:
brew install https://raw.github.com/Homebrew/homebrew-dupes/master/apple-gcc42.rb
Upgrading from Xcode 4.1 doesn't drop existing GCC support, so this formula is only useful if you're working with a fresh 4.2+ installation.
One option is to install MacPorts and install the gcc46 package:
sudo port install gcc46
Another option is to download the source code and build it as follows:
tar xzvf gcc-4.6.0.tar.gz
cd gcc-4.6.0
./configure
make
Note that GCC 4.6.0 requires as prerequisites GMP 4.2+, MPFR 2.3.1+, and MPC 0.8.0+. If ./configure fails, it's probably because you're missing one of these (though it should give you a helpful error message in any case).
Building will take a while—likely several hours, depending on your hardware.
I would suggest building it yourself (Adam details how to do so). This will give you fine control on where to install and all the options you want to select. My experience from having multiple versions of gcc is that, if care is not taken apple's version of gcc can be damaged.
To speed up gcc installation you might want to look at --enable-languages option. If there are languages you don't need installed with the new gcc then you may not want to select them.