Software/ROOT: Difference between revisions

From PBTWiki
Jump to navigation Jump to search
Line 32: Line 32:


These instructions were based off this [http://www.hep.ucl.ac.uk/pbt/wikiData/presentations/2019/EclipseRoot.pdf tutorial].
These instructions were based off this [http://www.hep.ucl.ac.uk/pbt/wikiData/presentations/2019/EclipseRoot.pdf 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 [https://visualstudio.microsoft.com/thank-you-downloading-visual-studio/?sku=Community&rel=16 Microsoft Visual Studio]
** There are many available components, you should just need the Workloads 'Desktop Development with C++' and 'Linux Development with C++'
* Install [https://root.cern.ch/downloading-root 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 [https://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/mingw-builds/installer/mingw-w64-install.exe/download?use_mirror=netix&r=https%3A%2F%2Fsourceforge.net%2Fprojects%2Fmingw-w64%2Ffiles%2F&use_mirror=netix] 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. <code>C:\MinGW_W64\mingw64\bin</code>
* Install [https://www.eclipse.org/downloads/ 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.

Revision as of 11:46, 30 March 2020

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 [3] 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
  • 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.