The source files can be downloaded from https://lhapdf.hepforge.org/downloads/
If you have a C++11 compiler, building LHAPDF >= 6.2 should be straightforward:
wget https://lhapdf.hepforge.org/downloads/?f=LHAPDF-6.X.Y.tar.gz -O LHAPDF-6.X.Y.tar.gz # ^ or use a web browser to download, which will get the filename correct tar xf LHAPDF-6.X.Y.tar.gz cd LHAPDF-6.X.Y ./configure --prefix=/path/for/installation make make install
You will then need to install PDF data files, most easily using the "lhapdf" manager script but also possible by manual download. See the LHAPDF website for details.
On systems where you want to use non-system compilers and libraries, the configure command will need to be a bit more complicated: see the following for more information.
Version 6.2.0 of LHAPDF, and later, have no external library dependencies. Earlier versions rely on the Boost C++ header library. We recommend upgrading to the current series to avoid that complication (and benefit from other improvements, too).
LHAPDF6 just needs your system to have a copy of Make and a C++11 compiler: there is no Fortran code and hence no need for gfortran. We have tested with both the g++ and clang++ compilers.
Note that fairly recent compiler versions are needed, to get C++11 support: g++ >= 4.8.5 and clang++ >= 3.3. The
-std=c++11 flag, if needed, will be added automatically by the LHAPDF configure script.
Building LHAPDF is typically straightforward on Linux systems, including CC7 and Ubuntu. Mac OS X, however, can cause problems due to inconsistent compiler and Python versions, and other such fun. If you want to build LHAPDF on a Mac, please see Building on Mac OS X.
If you want to build the Python interface to LHAPDF (which is very nice!), you will need the Python development headers to be installed (e.g. via the
python-dev Ubuntu package). If the
Python.h header is not found by
configure, no Python extension module will be built.
If you have downloaded a release tarball for LHAPDF 6.X.Y, unpack it with
tar xf LHAPDF-6.X.Y.tar.gz, then
cd to the newly-created directory.
cdto the new directory, but you must then also run
autoreconf -ibefore proceeding to the instructions below. There will also be more requirements for external packages if you build this way, since this is the "developer" route to building LHAPDF and requires a bit more expertise.
Now you should run the
configure script to analyse your machine, compiler, etc. and set up the Makefiles. You will probably need to provide the
--prefix argument to
configure to tell it where you want to install LHAPDF (probably you don't want to install to
/usr/local, which is the default). For example,
An example build script for LHAPDF6 on the CERN lxplus6 system is shown at the end of these instructions.
If you want to use an alternative C++ compiler, then you can specify the CXX variable on the command line. This is essential on OS X Mavericks and later, where the consistent compiler suite is clang rather than gcc – in that situation, use:
./configure --prefix=... CXX=clang++
The configure script will run and produce quite a bit of output from its various tests. Hopefully everything will be successful: if it gets to the end without stopping due to an error then all is well.
Then just call
make to build the library (or e.g.
make -j4 to compile 4 files in parallel – if your machine has enough processor cores to do so, even
-j2 will speed up the build quite a bit). To install LHAPDF to the
--prefix location that you specified, call
make install. You will (or at least should(!) find installed files in
CERN's lxplus7 system runs CC7 Linux, whose system compiler and Python installations are sufficiently modern to compile LHAPDF (although the system compiler is not an official LCG platform). No special environment setup is needed on lxplus7 unless you want to interface with precompiled LCG software.
By contrast the older lxplus6 system runs SLC6, for which the system compiler is neither supported by LCG nor LHAPDF: on this system you will need to set up a more modern LCG environment capable of compiling C++11 source code. Here is an example of how o build LHAPDF using LCG tools on lxplus6 (and lxplus7) – although you can of course use other compiler and Python versions, build flags, etc. if you wish.
## Set up LCG compiler & Python (required on SLC6/lxplus6, optional on CC7/lxplus7) source /cvmfs/sft.cern.ch/lcg/releases/LCG_87/gcc/4.9.3/x86_64-slc6/setup.sh source /cvmfs/sft.cern.ch/lcg/releases/LCG_87/Python/2.7.10/x86_64-slc6-gcc49-opt/Python-env.sh ## Make an install directory mkdir local ## Build LHAPDF wget https://lhapdf.hepforge.org/downloads/?f=LHAPDF-6.X.Y.tar.gz -O- | tar xz cd LHAPDF-6.X.Y ./configure --prefix=$PWD/../local make -j2 && make install cd .. ## Set environment variables export PATH=$PWD/local/bin:$PATH export LD_LIBRARY_PATH=$PWD/local/lib:$LD_LIBRARY_PATH export PYTHONPATH=$PWD/local/lib64/python2.6/site-packages:$PYTHONPATH ## Test the scripts lhapdf-config --help lhapdf list
Builds are typically straightforward on Linux, but Mac OS X unfortunately has a long history of incoherent system compiler setups, which have been worked around manually by users' private installations of Fink, MacPorts, HomeBrew and manual tarball installations of required tools. These work-arounds can themselves be the source of problems when the native compilers or Python libraries get updated, and due to the ad hoc nature of such installations we are restricted in how much we can help to get LHAPDF to compile on a broken system: it is the user's responsibility to make sure that their machine has a consistent set of build tools!
From experience, the simplest reliable route seems to be to run a fresh copy of OS X 10.9 Mavericks (or later) without any additional manual compiler installations: if you use the clang++ compiler on such a system, LHAPDF6 building should "just work".
export CFLAGS=-Qunused-argumentsbefore building. Alternatively you can run the configure script with
--disable-python, which avoids the bug at the cost of not building the very useful Python interface to LHAPDF.
The Mac OS X "Homebrew" system (http://brew.sh/) comes recommended by several LHAPDF developers. Many HEP packages are already available for Homebrew via the homebrew-hep project: http://davidchall.github.io/homebrew-hep/ . Success has also been reported with the MacPorts system (http://www.macports.org/). With both these approaches, you should set your environment to only use compilers and Python from the Brew/Ports area and to ignore the system packages: a hybrid approach will only cause unnecessary pain.