CMBEASY: How to compile on OS X
Posted: February 08 2005
I recently compiled CMBEASY on my Mac. Since this required
making a few changes to the source files and Makefile, I
thought it would be worth posting a record of the experience
somewhere so that other people don't have to figure this
out for themselves.
I assume that you want to install everything,
including the Markov-Chain and GUI, so some of
what I describe isn't be necessary if this is not desired.
These comments apply specifically to CMBEASY 3.0.1
and OS X 10.3.7.
First, you need to install LAM/MPI. There is a OS X
version available on the LAM/MPI website, so this
is trivial. Next you need to install qt (for the gui)
and gsl (Gnu Scientific Library). The easiest
way to install these is through fink, which most
of the people who might read this probably already
know about. If you are unfamiliar with fink,
take a look at http://fink.sourceforge.net/
If you prefer to install the GSL and QT3
some other way, good luck to you.
Specifically, the gsl and qt3 can be installed by
fink install qt3 qt3-dev gsl
If you get a complaint about not having gcc 2.95
available, that's because you used the default install
when you installed the xcode tools. Go back to your
xcode cd (or disk image, whatever) and use the
package installer. This time do a custom install,
and add gcc 2.95 to the list of packages you want.
Fink installs the qt3 headers in a slightly unusual
location, so you will have to make some changes
to the Makefile. More on that in a bit.
As indicated in the INSTALLATION file, there are
some environment variables that need to be
set. I'll leave CMBEASYDIR up to you, but assuming
that you put fink in the usual place (/sw), the
other two variables should be set via something
like:
setenv QTCMB /sw
setenv GSLCMBDIR /sw
If you don't use tcsh, modify these appropriately.
Then edit the makefile. Replace $(QTCMB)/include
with $(QTCMB)/include/qt both places that it appears.
That should take care of setting up the libraries.
Next, you need to make some changes to the source code.
There is some bug with the Apple supplied standard c libraries
that causes the isnan and isinf macros to be hidden if
#include<iostream> is used. Hopefully somebody will fix
this someday, but in the meantime there are two ways
to proceed. The first is to add the flag
-D_GLIBCPP_USE_C99 to the compile options. I wouldn't
recommend this, because it interferes with some other things.
The easier solution is to add the following two lines
extern "C" int isnan(double);
extern "C" int isinf(double);
after the #include statements in the following files:
cosmos/quintcosmos.cc
cosmos/perturbation.cc
anisotropy/analyzethis.cc
anisotropy/mc_general.cc
chain/chainshop.cc
chain/lowlevelplot.cc
Finally, one other change. The hcp command
used to make bin/mc_general has to -o 's in it.
hcp doesn't seem to like this. My solution was
to remove the first one ( -o mc_xgeneral ).
hcp only appears once in the makefile, so this
should be easy to find.
Okay, with those changes in place:
make
make bin/mc_general
and everything should compile, and, at least
as far as I can tell, work.
making a few changes to the source files and Makefile, I
thought it would be worth posting a record of the experience
somewhere so that other people don't have to figure this
out for themselves.
I assume that you want to install everything,
including the Markov-Chain and GUI, so some of
what I describe isn't be necessary if this is not desired.
These comments apply specifically to CMBEASY 3.0.1
and OS X 10.3.7.
First, you need to install LAM/MPI. There is a OS X
version available on the LAM/MPI website, so this
is trivial. Next you need to install qt (for the gui)
and gsl (Gnu Scientific Library). The easiest
way to install these is through fink, which most
of the people who might read this probably already
know about. If you are unfamiliar with fink,
take a look at http://fink.sourceforge.net/
If you prefer to install the GSL and QT3
some other way, good luck to you.
Specifically, the gsl and qt3 can be installed by
fink install qt3 qt3-dev gsl
If you get a complaint about not having gcc 2.95
available, that's because you used the default install
when you installed the xcode tools. Go back to your
xcode cd (or disk image, whatever) and use the
package installer. This time do a custom install,
and add gcc 2.95 to the list of packages you want.
Fink installs the qt3 headers in a slightly unusual
location, so you will have to make some changes
to the Makefile. More on that in a bit.
As indicated in the INSTALLATION file, there are
some environment variables that need to be
set. I'll leave CMBEASYDIR up to you, but assuming
that you put fink in the usual place (/sw), the
other two variables should be set via something
like:
setenv QTCMB /sw
setenv GSLCMBDIR /sw
If you don't use tcsh, modify these appropriately.
Then edit the makefile. Replace $(QTCMB)/include
with $(QTCMB)/include/qt both places that it appears.
That should take care of setting up the libraries.
Next, you need to make some changes to the source code.
There is some bug with the Apple supplied standard c libraries
that causes the isnan and isinf macros to be hidden if
#include<iostream> is used. Hopefully somebody will fix
this someday, but in the meantime there are two ways
to proceed. The first is to add the flag
-D_GLIBCPP_USE_C99 to the compile options. I wouldn't
recommend this, because it interferes with some other things.
The easier solution is to add the following two lines
extern "C" int isnan(double);
extern "C" int isinf(double);
after the #include statements in the following files:
cosmos/quintcosmos.cc
cosmos/perturbation.cc
anisotropy/analyzethis.cc
anisotropy/mc_general.cc
chain/chainshop.cc
chain/lowlevelplot.cc
Finally, one other change. The hcp command
used to make bin/mc_general has to -o 's in it.
hcp doesn't seem to like this. My solution was
to remove the first one ( -o mc_xgeneral ).
hcp only appears once in the makefile, so this
should be easy to find.
Okay, with those changes in place:
make
make bin/mc_general
and everything should compile, and, at least
as far as I can tell, work.