Software/ROOT
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
.
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.14.00 on MacOS: "/Applications/root_v6.14.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: DYLD_LIBRARY_PATH, Value: /Applications/root_v6.14.00/lib
- Name: ROOTSYS, Value: /Applications/root_v6.14.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.14.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'.
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
- Name:
- 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.