Software/ROOT: Difference between revisions

From PBTWiki
Jump to navigation Jump to search
 
(11 intermediate revisions by the same user not shown)
Line 26: Line 26:
*Then add the line:
*Then add the line:
<code>. /home/pi/ROOT/install/bin/thisroot.sh</code> to <code>.bashrc</code> in <code>/home/pi</code> to source ROOT every time a new terminal is opened.
<code>. /home/pi/ROOT/install/bin/thisroot.sh</code> to <code>.bashrc</code> in <code>/home/pi</code> to source ROOT every time a new terminal is opened.
'''Raspberry Pi OS''' has slightly changed the procedure for installing ROOT.
*Install required dependencies:
<code> sudo apt-get install dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev python3 libssl-dev git </code>
*Install optional dependencies:
<code> sudo apt-get install gfortran libpcre3-dev xlibmesa-glu-dev libglew1.5-dev libftgl-dev libmariadb-dev libfftw3-dev libcfitsio-dev graphviz-dev libavahi-compat-libdnssd-dev libldap2-dev python3-dev libxml2-dev libkrb5-dev libgsl0-dev </code>
* Download the source code from official ROOT CERN webpage, and unpack.
<code> tar -xzvf rootfolder.tar </code>
* Create a src file
* Go to the build directory and excute:
<code> LDFLAGS="-L/usr/lib/gcc/arm-linux-gnueabihf/8/ -latomic" cmake -DCMAKE_INSTALL_PREFIX=../install .. </code>
then
<code>LDFLAGS="-L/usr/lib/gcc/arm-linux-gnueabihf/8/ -latomic" cmake --build . --target install -j4</code>
* We need to source root. In the .bashrc file we add the following line:
<code> source /home/pi/root-6.30.02/build/bin/thisroot.sh </code>
== Local instalation on NUC ==
NUC runs on CentOS, so the best way to install ROOT is through a package manager (Snap in this case).
* Snaps is available from the Extra Packages for Enterprise Linux (EPEL) repository, so we first need to add the EPEL repository.
<code> sudo yum install epel-release </code>
* Install the package manager (Snap)
<code> sudo yum install snapd  </code>
* Enable systemd unit that manages Snap communication socket
<code> sudo systemctl enable --now snapd.socket </code>
*  create a symbolic link between /var/lib/snapd/snap and /snap
<code> sudo ln -s /var/lib/snapd/snap /snap </code>
* We log out and restart the terminal to make sure everything is OK
* Install ROOT via Snap.
<code> sudo snap install root-framework </code>


== Using ROOT in Eclipse IDE on MacOS ==
== Using ROOT in Eclipse IDE on MacOS ==

Latest revision as of 12:08, 26 January 2024

Local Installation on MacOS

Correct for MacOS High Sierra 10.13.6

  • Install Xcode from the Mac App Store. (Note: If using an older version of MacOS, previous versions of Xcode can be found here: [1])
  • Enable command line tools for Xcode using the terminal command: xcode-select --install.
  • Download and run the ROOT dmg from CERN: [2]
  • Navigate to your user folder in Finder, use CMD+SHIFT+. to show hidden files, one of which will be .bash_profile.
  • Edit the text file by adding the line: . <pathname>/root/bin/thisroot.sh (where <pathname> is the directory that leads to the folder ROOT is installed in, noting that the folder root typically has a version number attached to it)
  • If your .bash_profile is locked, add permissions by selecting “Get Info” and unlocking the file/giving yourself read and write privileges.
  • You can now run ROOT in terminal by typing root.

Local Installation on Raspbian

  • Install required dependencies:

sudo apt-get install dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev python libssl-dev git

  • Install optional dependencies:

sudo apt-get install gfortran libpcre3-dev xlibmesa-glu-dev libglew1.5-dev libftgl-dev libmariadb-dev libfftw3-dev libcfitsio-dev graphviz-dev libavahi-compat-libdnssd-dev libldap2-dev python-dev libxml2-dev libkrb5-dev libgsl0-dev libqt4-dev

  • After unpacking the source code, execute in the build directory:

LDFLAGS="-L/usr/lib/gcc/arm-linux-gnueabihf/8/ -latomic" cmake -DCMAKE_INSTALL_PREFIX=../install ../src

  • And then build:

LDFLAGS="-L/usr/lib/gcc/arm-linux-gnueabihf/8/ -latomic" cmake --build . --target install -j4

  • Then add the line:

. /home/pi/ROOT/install/bin/thisroot.sh to .bashrc in /home/pi to source ROOT every time a new terminal is opened.


Raspberry Pi OS has slightly changed the procedure for installing ROOT.

  • Install required dependencies:

sudo apt-get install dpkg-dev cmake g++ gcc binutils libx11-dev libxpm-dev libxft-dev libxext-dev python3 libssl-dev git

  • Install optional dependencies:

sudo apt-get install gfortran libpcre3-dev xlibmesa-glu-dev libglew1.5-dev libftgl-dev libmariadb-dev libfftw3-dev libcfitsio-dev graphviz-dev libavahi-compat-libdnssd-dev libldap2-dev python3-dev libxml2-dev libkrb5-dev libgsl0-dev

  • Download the source code from official ROOT CERN webpage, and unpack.

tar -xzvf rootfolder.tar

  • Create a src file
  • Go to the build directory and excute:

LDFLAGS="-L/usr/lib/gcc/arm-linux-gnueabihf/8/ -latomic" cmake -DCMAKE_INSTALL_PREFIX=../install ..

then

LDFLAGS="-L/usr/lib/gcc/arm-linux-gnueabihf/8/ -latomic" cmake --build . --target install -j4

  • We need to source root. In the .bashrc file we add the following line:

source /home/pi/root-6.30.02/build/bin/thisroot.sh

Local instalation on NUC

NUC runs on CentOS, so the best way to install ROOT is through a package manager (Snap in this case).

  • Snaps is available from the Extra Packages for Enterprise Linux (EPEL) repository, so we first need to add the EPEL repository.

sudo yum install epel-release

  • Install the package manager (Snap)

sudo yum install snapd

  • Enable systemd unit that manages Snap communication socket

sudo systemctl enable --now snapd.socket

  • create a symbolic link between /var/lib/snapd/snap and /snap

sudo ln -s /var/lib/snapd/snap /snap

  • We log out and restart the terminal to make sure everything is OK
  • Install ROOT via Snap.

sudo snap install root-framework

Using ROOT in Eclipse IDE on MacOS

C++ code for analysis of data from LeCroy Oscilloscope and QUARC exist in pre-compiled software, edited in Eclipse and containing a rudimentary text-based interface to minimise programming knowledge required for usage. These instructions detail how to allow a C/C++ Eclipse project to access ROOT's libraries.

  • First, locate the directory where ROOT is installed on your computer, e.g. for ROOT v6.20.00 on MacOS: "/Applications/root_v6.20.00". The following instructions will use this path as an example.
  • Right-click on the project and select properties (shortcut: CMD+I)
  • Navigate to C/C++ Build –> Environment and add the variables:
    • Name: LD_LIBRARY_PATH, Value: /Applications/root_v6.20.00/lib
    • Name: ROOTSYS, Value: /Applications/root_v6.20.00
  • Navigate to C/C++ Build –> Settings –> Tool Settings –> MacOS X C++ Linker –> Libraries
    • Add the libraries, in individual entries and in this order (exclude commas): Gui, Core, Imt, RIO, Net, Hist, Graf, Graf3d, Gpad, ROOTDataFrame, ROOTVecOps, Tree, TreePlayer, Rint, Postscript, Matrix, Physics, MathCore, Thread, MultiProc, pThread, m, dl
    • Add the library search path: /Applications/root_v6.20.00/lib
  • Navigate to MacOS X C++ Linker –> Miscellaneous and add (replacing if needed): -pthread -stdlib=libc++ -std=c++11 -m64
  • Navigate to GCC C++ Compiler –> Includes and add the include path: /Applications/root_v6.14.00/include
  • Navigate to GCC C++ Compiler –> Optimization
    • Change the Optimization Level to "Optimize most (-O3)
    • Add the following Other Optimization Flags (replacing if needed): -pthread -stdlib=libc++ -std=c++11 -m64
  • Navigate to GCC C++ Compiler –> Miscellaneous and add (replacing if needed): -c -fmessage-length=0 -pthread -stdlib=libc++ -std=c++11 -m64
  • Repeat the instructions for GCC C++ Compiler for GCC C Compiler if you wish to write/edit C code'. Otherwise, ensure that all C++ source files which are not headers have the file extension '.cpp'.
  • Navigate to C/C++ General -> Preprocessor Include Paths, Macros etc. -> Providers. Select CDT GCC Built-in Compiler Settings and add the flag -std=c++11

These instructions were based off this tutorial.

Using ROOT in Eclipse IDE on Windows 10

Some hardware-related software is only available on Windows, hence it may be useful to be able to edit, compile and run ROOT-based analysis on Windows as well.

  • Install Microsoft Visual Studio
    • There are many available components, you should just need the Workloads 'Desktop Development with C++' and 'Linux Development with C++'
  • Install ROOT
    • Choose the option to add ROOT to the system PATH for all users.
    • It's best to install ROOT on the top level of the C drive.
  • Install MinGW-w64, the 64-bit version of the MinGW compiler.
    • Choose the x86_64 architecture and posix threads.
    • Again, it's best to install on the top level of the C drive.
    • In Windows Explorer, right-click on This PC and select Properties -> Advanced System Settings -> Environment Variables. Edit the PATH variable to include MinGW by the appropriate path for your installation, e.g. C:\MinGW_W64\mingw64\bin
  • At this point, you should be able to run ROOT in Command Prompt by typing root, perhaps first requiring a restart.
  • Install Eclipse IDE
    • Choose 'Eclipse IDE for C/C++ Developers'
    • Once the IDE is installed, set up a new Hello World C++ project with the 'C++ Managed Build', choosing the MinGW GCC toolchain.
    • Under the Help tab, choose 'Install new software'. Select to work with all available sites. Under 'Programming Languages', select C/C++ Development Tools and C/C++ Development Tools SDK if they haven't been installed already (note: default option is to hide already installed packages).
  • For good measure, close all applications and restart the computer.

Eclipse Project Settings

Use your appropriate ROOT installation path, the path used below is an example. These instructions have been adapted from the MacOS instructions and so some steps may not be appropriate for Windows. As of yet, projects do not compile, please see known issues below.

  • Right-click on the project and select properties
  • Navigate to C/C++ Build –> Environment and add the variables:
    • Name: LD_LIBRARY_PATH, Value: C:\root_v6.18.04\lib
    • Name: ROOTSYS, Value: C:\root_v6.18.04
  • Navigate to C/C++ Build –> Settings –> Tool Settings –> MinGW C++ Linker –> Libraries
    • Add the libraries, in individual entries and in this order (exclude commas): Gui, Core, Imt, RIO, Net, Hist, Graf, Graf3d, Gpad, ROOTDataFrame, ROOTVecOps, Tree, TreePlayer, Rint, Postscript, Matrix, Physics, MathCore, Thread, MultiProc, pThread, m, dl
    • Add the library search path: C:\root_v6.18.04\lib
  • Navigate to MinGW C++ Linker –> Miscellaneous and add (replacing if needed): -pthread -std=c++11 -m64
  • Navigate to GCC C++ Compiler –> Includes and add the include path: C:\root_v6.18.04\include
  • Navigate to GCC C++ Compiler –> Optimization
    • Change the Optimization Level to "Optimize most (-O3)
    • Add the following Other Optimization Flags (replacing if needed): -pthread -std=c++11 -m64
  • Navigate to GCC C++ Compiler –> Miscellaneous and add (replacing if needed): -c -fmessage-length=0 -fpermissive -pthread -std=c++11 -m64
  • Repeat the instructions for GCC C++ Compiler for GCC C Compiler if you wish to write/edit C code'. Otherwise, ensure that all C++ source files which are not headers have the file extension '.cpp'.

Known Issues

  • The flag added in the compiler settings earlier, -fpermissive, suppresses the error (which will appear now as warnings) of the lost precision when some of ROOT's libraries convert variables that, in the 64-bit MinGW compiler, are too large to be stored completely in the new variable type. It's probably bad practice to suppress such warnings and it is unclear if this will have any adverse effects. This is not an issue in the regular MinGW compiler, however that has issues related to thread models that are fixed by using the 64-bit compiler.
  • By following these instructions, code should not compile. For some reason, the linker is unable to find the ROOT libraries that were listed individually. As far as can be seen, this practice should be carried over from the MacOS instructions, but it is unclear why these libraries cannot be found. This error persists when attempting to build with Cygwin as well.