| <p>These are instructions I put together as I was first figuring out how to compile PueoSim/NiceMC. This was originally done on machines running CentOS 7, however has since been replicated on the OSC machines (running RedHat 7.9 I think?). I generally try to avoid any `module load` type prerequisites, instead opting to compile any dependencies from source. You _might_ be able to get this to work by `module load`ing e.g. fftw, but try this at your own peril.</p>
<p>#pueoBuilder Installation Tutorial</p>
<p>This tutorial will guide you through the process of building the tools included in pueoBuilder from scratch, including the prerequisites and any environment variables that you will need to set. This sort of thing is always a bit of a nightmare process for me, so hopefully this guide can help you skip some of the frustration that I ran into. I did not have root acces on the system I was building on, so the instructions below are what I had to do to get things working with local installations. If you have root access, then things might be a bit easier. For reference I'm working on CentOS 7, other operating systems might have different problems that arise. </p>
<p>##Prerequisites<br />
As far as I can tell, the prerequisites that need to be built first are:</p>
<p>-Python 3.9.18 (Apr. 6 2024 edit by Jason Yao, needed for ROOT 6.26-14)<br />
-cmake 3.21.2 (I had problems with 3.11.4)<br />
-gcc 11.1.0 (9.X will not work) (update 4/23/24: If you are trying to compile ROOT 6.30, you might need to downgrade to gcc 10.X, see note about TBB in "Issues I ran into" at the end)<br />
-fftw 3.3.9<br />
-gsl 2.7.1 (for ROOT)<br />
-ROOT 6.24.00<br />
-OneTBB 2021.12.0 (if trying to compile ROOT 6.30)</p>
<p>###CMake<br />
You can download the source files for CMake here: https://cmake.org/download/. Untar the source files with:</p>
<p> tar -xzvf cmake-3.22.1.tar.gz</p>
<p>Compiling CMake is as easy as following the directions on the website: https://cmake.org/install/, but since we're doing a local build, we'll use the `configure` script instead of the listed `bootstrap` script. As an example, suppose that I downloaded the above tar file to `/scratch/wluszczak/cmake`: </p>
<p> mkdir install<br />
cd cmake-3.22.1<br />
./configure --prefix=/scratch/wluszczak/cmake/install<br />
make<br />
make install</p>
<p>You should additionally add this directory to your `$PATH` variable:</p>
<p> export PATH=/scratch/wluszczak/cmake/install/bin:$PATH<br />
</p>
<p>To check to make sure that you are using the correct version of CMake, run:</p>
<p> cmake --version</p>
<p>and you should get:</p>
<p> cmake version 3.22.1</p>
<p> CMake suite maintained and supported by Kitware (kitware.com/cmake).</p>
<p>### gcc 11.1.0</p>
<p>Download the gcc source from github here: https://github.com/gcc-mirror/gcc/tags. I used the 11.1.0 release, though there is a more recent 11.2.0 release that I have not tried. Once you have downloaded the source files, untar the directory:</p>
<p> tar -xzvf gcc-releases-gcc-11.1.0.tar.gz</p>
<p>Then install the prerequisites for gcc:<br />
<br />
cd gcc-releases-gcc-11.1.0<br />
contrib/download_prerequisites</p>
<p>One of the guides I looked at also recommended installing flex separately, but I didn't seem to need to do this, and I'm not sure how you would go about it without root priviledges, though I imagine it's similar to the process for all the other packages here (download the source and then build by providing an installation prefix somewhere)</p>
<p>After you have installed the prerequisites, create a build directory:</p>
<p> cd ../<br />
mkdir build<br />
cd build</p>
<p>Then configure GCC for compilation like so:</p>
<p> ../gcc-releases-gcc-11.1.0/configure -v --prefix=/home/wluszczak/gcc-11.1.0 --enable-checking=release --enable-languages=c,c++,fortran --disable-multilib --program-suffix=-11.1</p>
<p>I don't remember why I installed to my home directory instead of the /scratch/ directories used above. In principle the installation prefix can go wherever you have write access. Once things have configured, compile gcc with:</p>
<p> make -j $(nproc)<br />
make install</p>
<p>Where `$(nproc)` is the number of processing threads you want to devote to compilation. More threads will run faster, but be more taxing on your computer. For reference, I used 8 threads and it took ~15 min to finish. </p>
<p><br />
Once gcc is built, we need to set a few environment variables:</p>
<p> export PATH=/home/wluszczak/gcc-11.1.0/bin:$PATH<br />
export LD_LIBRARY_PATH=/home/wluszczak/gcc-11.1.0/lib64:$LD_LIBRARY_PATH</p>
<p>We also need to make sure cmake uses this compiler:</p>
<p> export CC=/home/wluszczak/gcc-11.1.0/bin/gcc-11.1<br />
export CXX=/home/wluszczak/gcc-11.1.0/bin/g++-11.1<br />
export FC=/home/wluszczak/gcc-11.1.0/bin/gfortran-11.1</p>
<p>If your installation prefix in the configure command above was different, substitute that directory in place of `/home/wluszczak/gcc-11.1.0` for all the above export commands. To easily set these variables whenever you want to use gcc-11.1.0, you can stick these commands into a single shell script:</p>
<p> #load_gcc11.1.sh<br />
export PATH=/home/wluszczak/gcc-11.1.0/bin:$PATH<br />
export LD_LIBRARY_PATH=/home/wluszczak/gcc-11.1.0/lib64:$LD_LIBRARY_PATH</p>
<p> export CC=/home/wluszczak/gcc-11.1.0/bin/gcc-11.1<br />
export CXX=/home/wluszczak/gcc-11.1.0/bin/g++-11.1<br />
export FC=/home/wluszczak/gcc-11.1.0/gfortran-11.1</p>
<p>(again substituting your installation prefix in place of mine). You can then set all these environment variables by simply running:<br />
<br />
source load_gcc11.1.sh</p>
<p>Once this is done, you can check that gcc-11.1.0 is properly installed by running:</p>
<p> gcc-11.1 --version</p>
<p>Note that plain old</p>
<p> gcc --version</p>
<p>might still point to an older version of gcc. This is fine though. </p>
<p>###FFTW 3.3.9<br />
Grab the source code for the appropriate versino of FFTW from here: http://www.fftw.org/download.html</p>
<p>However, do NOT follow the installation instructions on the webpage. Those instructions might work if you have root privileges, but I personally couldn't seem to to get things to work that way. Instead, we're going to build fftw with cmake. Untar the fftw source files:</p>
<p> tar -xzvf fftw-3.3.9.tar.gz</p>
<p>Make a build directory and cd into it:<br />
<br />
mkdir build<br />
cd build</p>
<p>Now build using cmake, using the flags shown below. For reference, I downloaded and untarred the source file in `/scratch/wluszczak/fftw/build`, so adjust your install prefix accordingly to point to your own build directory that you created in the previous step.</p>
<p> cmake -DCMAKE_INSTALL_PREFIX=/scratch/wluszczak/fftw/build/ -DBUILD_SHARED_LIBS=ON -DENABLE_OPENMP=ON -DENABLE_THREADS=ON ../fftw-3.3.9<br />
make install -j $(nproc)</p>
<p>Now comes the weird part. Remove everything except the `include` and `lib64` directories in your build directory (if you installed to a different `CMAKE_INSTALL_PREFIX`, the include and lib64 directories might be located there instead. The important thing is that you want to remove everything, but leave the `include` and `lib64` directories untouched):</p>
<p> rm *<br />
rm -r CMakeFiles</p>
<p>Now rebuild fftw, but with an additional flag:</p>
<p> cmake -DCMAKE_INSTALL_PREFIX=/scratch/wluszczak/fftw/build/ -DBUILD_SHARED_LIBS=ON -DENABLE_OPENMP=ON -DENABLE_THREADS=ON -DENABLE_FLOAT=ON ../fftw-3.3.9<br />
make install -j $(nproc)</p>
<p>At the end of the day, your fftw install directory should have the following files:</p>
<p> include/fftw3.f <br />
include/fftw3.f03<br />
include/fftw3.h <br />
include/fftw3l.f03 <br />
include/fftw3q.f03 <br />
lib64/libfftw3f.so <br />
lib64/libfftw3f_threads.so.3 <br />
lib64/libfftw3_omp.so.3.6.9 <br />
lib64/libfftw3_threads.so<br />
lib64/libfftw3f_omp.so <br />
lib64/libfftw3f.so.3 <br />
lib64/libfftw3f_threads.so.3.6.9 <br />
lib64/libfftw3.so <br />
lib64/libfftw3_threads.so.3<br />
lib64/libfftw3f_omp.so.3 <br />
lib64/libfftw3f.so.3.6.9 <br />
lib64/libfftw3_omp.so <br />
lib64/libfftw3.so.3 <br />
lib64/libfftw3_threads.so.3.6.9<br />
lib64/libfftw3f_omp.so.3.6.9 <br />
lib64/libfftw3f_threads.so <br />
lib64/libfftw3_omp.so.3 <br />
lib64/libfftw3.so.3.6.9</p>
<p>Why do we have to do things this way? I don't know, I'm bad at computers. Maybe someone more knowledgeable knows. I found that when I didn't do this step, I'd run into errors that pueoBuilder could not find some subset of the required files (either the ones added by building with `-DENABLE_FLOAT`, or the ones added by building without `-DENABLE_FLOAT`). </p>
<p>Once fftw has been installed, export your install directory (the one with the include and lib64 folders) to the following environment variable:</p>
<p> export FFTWDIR=/scratch/wluszczak/fftw/build</p>
<p>Again, substituting your own fftw install prefix that you used above in place of `/scratch/wluszczak/fftw/build`</p>
<p>###gsl 2.7.1<br />
gsl 2.7.1 is needed for the `mathmore` option in ROOT. If you have an outdated version of gsl, ROOT will still compile, but it will skip installing `mathmore` and `root-config --has-mathmore` will return `no`. To fix this, grab the latest source code for gsl from here: https://www.gnu.org/software/gsl/. Untar the files to a directory of your choosing:</p>
<p> tar -xzvf gsl-latest.tar.gz</p>
<p>For some reason I also installed gsl to my home directory, but in principle you can put it wherever you want. </p>
<p> mkdir /home/wluszczak/gsl<br />
./configure --prefix=/home/wluszczak/gsl<br />
make<br />
make check<br />
make install</p>
<p>To make sure ROOT can find this installation of gsl, you'll again need to set an environment variable prior to building ROOT:</p>
<p> export GSL_ROOT_DIR=/home/wluszczak/gsl/<br />
<br />
I also added this to my $PATH variable, though I don't remember if that was required to get things working or not:</p>
<p> export PATH=/home/wluszczak/gsl/bin/:$PATH <br />
export LD_LIBRARY_PATH=/home/wluszczak/gsl/lib:$LD_LIBRARY_PATH</p>
<p> </p>
<p>###Python 3.9.18<br />
Apr. 6, 2024 edit by Jason Yao:<br />
I was able to follow this entire ELOG to install root 6.24.00, but I also was getting warnings/errors that seem to be related to Python,<br />
so I went ahead and installed Python 3.9.18 (and then a newer version of ROOT just for fun).<br />
Note that even though we can `module load python/3.9-2022.05` on OSC, I am 90% sure that this provided Python instance is no good as far as ROOT is concerned.<br />
<br />
Head over to <a href="https://www.python.org/downloads/release/python-3918/">https://www.python.org/downloads/release/python-3918/</a> to check out the source code.<br />
You can run<br />
wget https://www.python.org/ftp/python/3.9.18/Python-3.9.18.tgz<br />
to download it on OSC; then, run<br />
tar -xzvf Python-3.9.18.tgz<br />
cd Python-3.9.18</p>
<p>Next we will compile Python from source. I used <a href="https://www.build-python-from-source.com/">this website</a> for this step.<br />
I wanted to install to `${HOME}/usr/Python-3.9.18/install`, so<br />
./configure --prefix=${HOME}/usr/Python-3.9.18/install --enable-shared<br />
Note that we <strong>must</strong> have the flag `--enable-shared` "to ensure that shared libraries are built for Python. By not doing this you are preventing any application which wants to use Python as an embedded environment from working" according to <a href="https://github.com/docker-library/python/issues/21">this guy</a>.<br />
(The corresponding error when you try to compile ROOT later on would look like "...can not be used when making a shared object; recompile with -fPIC...")</p>
<p>After configuration,<br />
make -j8 && make install<br />
(using 8 threads)</p>
<p>After installation, head over to the install directory, and then<br />
cd bin<br />
You should see `pip3` and `python3.9`. If you run<br />
./python3<br />
you should see the Python interactive terminal<br />
Python 3.9.18 (main, Apr 5 2024, 22:49:51) <br />
[GCC 11.1.0] on linux<br />
Type "help", "copyright", "credits" or "license" for more information.<br />
>>><br />
Add the python3 in this folder to your PATH variable. For example, <br />
export PATH=${HOME}/usr/Python-3.9.18/install/bin:${PATH}<br />
</p>
<p>While we are in the python install directory, we might as well also use the `pip3` there to install numpy:<br />
./pip3 install numpy<br />
(I am not sure if this is absolutely needed by ROOT, but probably)</p>
<p>Next comes the important bit. You need to add the `lib/` directory inside you python installation to the environment variable $LD_LIBRARY_PATH<br />
export LD_LIBRARY_PATH=${HOME}/usr/Python-3.9.18/install/lib:$LD_LIBRARY_PATH<br />
according to <a href="https://stackoverflow.com/questions/43333207/python-error-while-loading-shared-libraries-libpython3-4m-so-1-0-cannot-open">stackoverflow</a>. Without this step I ran into errors when compiling ROOT.</p>
<p> </p>
<p>###ROOT 6.24.00<br />
Download the specific version of ROOT that you need from here: https://root.cern/install/all_releases/</p>
<p>You might need to additionally install some of the dependencies (https://root.cern/install/dependencies/), but it seems like everything I needed was already installed on my system. </p>
<p>Untar the source you downloaded:<br />
<br />
tar -xzvf root_v6.24.00.source.tar.gz</p>
<p>Make some build and install directories:</p>
<p> mkdir build install<br />
cd build</p>
<p>Run CMake, but be sure to enable the fortan, mathmore and minuit2 options. For reference, I had downloaded and untarred the source files to `/scratch/wluszczak/root`. Your installation and source paths will be different.</p>
<p> cmake -DCMAKE_INSTALL_PREFIX=/scratch/wluszczak/root/install/ /scratch/wluszczak/root/root-6.24.00/ -Dfortran=ON -Dminuit2=ON -Dmathmore=ON</p>
<p>Note: if you end up with an error related to compiling XROOTD, then add -Dxrootd=OFF to the original cmake command above.</p>
<p>Then proceed to start the build:</p>
<p> cmake --build . --target install -j $(nproc)<br />
</p>
<p>If everything has worked then after the above command finishes running, you should be able to run the following file to finish setting up ROOT:</p>
<p> source ../install/bin/thisroot.sh</p>
<p>##pueoBuilder<br />
By this point, you should have working installations of CMake 3.21.2, gcc-11.1.0, fftw 3.3.9, and ROOT 6.24.00. Additionally, the following environment variables should have been set:</p>
<p> export PATH=/scratch/wluszczak/cmake/install/bin:$PATH</p>
<p> export PATH=/home/wluszczak/gcc-11.1.0/bin:$PATH<br />
export LD_LIBRARY_PATH=/home/wluszczak/gcc-11.1.0/lib64:$LD_LIBRARY_PATH</p>
<p> export CC=/home/wluszczak/gcc-11.1.0/bin/gcc-11.1<br />
export CXX=/home/wluszczak/gcc-11.1.0/bin/g++-11.1<br />
export FC=/home/wluszczak/gcc-11.1.0/gfortran-11.1</p>
<p> export FFTWDIR=/scratch/wluszczak/fftw/build</p>
<p>At this point, the hard work is mostly done. Check out pueoBuilder with:</p>
<p> git clone git@github.com:PUEOCollaboration/pueoBuilder </p>
<p>set the following environment variables:</p>
<p> export PUEO_BUILD_DIR=/scratch/wluszczak/PUEO/pueoBuilder<br />
export PUEO_UTIL_INSTALL_DIR=/scratch/wluszczak/PUEO/pueoBuilder<br />
export NICEMC_SRC=${PUEO_BUILD_DIR}/components/nicemc<br />
export NICEMC_BUILD=${PUEO_BUILD_DIR}/build/components/nicemc<br />
export PUEOSIM_SRC=${PUEO_BUILD_DIR}/components/pueoSim<br />
export LD_LIBRARY_PATH=${PUEO_UTIL_INSTALL_DIR}/lib:$LD_LIBRARY_PATH</p>
<p>Where $PUEO_BUILD_DIR and $PUEO_UTIL_INSTALL_DIR point to where you cloned pueoBuilder to (in my case, `/scratch/wluszczak/PUEO/pueoBuilder`. Now you should be able to just run:</p>
<p> ./pueoBuilder.sh</p>
<p>Perform a prayer to the C++ gods while you're waiting for it to compile, and hopefully at the end of the day you'll have a working set of PUEO software. </p>
<p>##Issues I Ran Into<br />
If you already have an existing installation of ROOT, you may still need to recompile to make sure you're using the same c++ standard that the PUEO software is using. I believe the pre-compiled ROOT binaries available through their website are insufficient, though maybe someone else has been able to get those working. </p>
<p>If you're running into errors about c++ standard or compiler version even after you have installed gcc-11.1.0, then for some reason your system isn't recognizing your local installation of gcc-11.1.0. Check the path variables ($PATH and $LD_LIBRARY_PATH) to make sure the gcc-11.1.0 `bin` directory is being searched.</p>
<p>If you're running into an error that looks like:<br />
<br />
CMake Error: The following variables are used in this project, but they are set to NOTFOUND.<br />
Please set them or make sure they are set and tested correctly in the CMake files:<br />
FFTWF_LIB (ADVANCED)</p>
<p>then pueoBuilder can't seem to find your fftw installation (or files that are supposed to be included in that installation), try rebuilding with different flags according to which files it seems to think are missing.</p>
<p>If it seems like pueoBuilder can't seem to find your fftw installation at all (i.e. you're getting some error that looks like `missing: FFTW_LIBRARIES` or `missing: FFTW_INCLUDES`), check the environment variables that are supposed to point to your fftw installation (`$FFTWDIR`) and make sure there are the correct files in the `lib` and `include` subdirectories. </p>
<p>Update: 6/23/24: The latest version of ROOT (6.30) will fail to compile on OSC unless you manually compile TBB as well. An easy workaround is to simply downgrade to ROOT 6.24, however if you really need ROOT 6.30 you can follow the instructions below to install TBB and compile ROOT:</p>
<p>You will first need to downgrade to GCC 10.X. TBB will not compile with GCC 11. This can be done by following the GCC installation isntructions above, except starting with GCC 10 source code instead of GCC 11.</p>
<p>To install TBB yourself, download the source code (preferably the .tar.gz file) from here: https://github.com/oneapi-src/oneTBB/releases/tag/v2021.12.0. Move the file to the directory where you want to install TBB and untar it with:</p>
<p> tar -xzvf oneTBB-2021.12.0.tar.gz</p>
<p>Make some build and install directories:</p>
<p> mkdir build install<br />
cd build</p>
<p>Then configure cmake:</p>
<p> cmake -DCMAKE_INSTALL_PREFIX=/path/to/tbb/install</p>
<p>Then compile with:</p>
<p> cmake --build .</p>
<p>Once this has finished running, you can add the installation to you $PATH and $LD_LIBRARY_PATH variables:</p>
<p> export PATH=/path/to/tbb/install/bin:$PATH<br />
export LD_LIBRARY_PATH=/path/to/tbb/install/lib64:$LD_LIBRARY_PATH</p>
<p>You can then proceed as normal, except when compiling root you will need one additional cmake flag (Dbuiltin_tbb=ON):</p>
<pre>
cmake -DCMAKE_INSTALL_PREFIX=/scratch/wluszczak/root/install/ /scratch/wluszczak/root/root-6.24.00/ -Dfortran=ON -Dminuit2=ON -Dmathmore=ON <code>-Dbuiltin_tbb=ON</code></pre>
<p><code>And hopefully this should work. This process is a little bit more involved than just downgrading ROOT, so try to avoid going down this route unless absolutely necessary. </code></p>
<p> </p> |