Home | News | Documentation | Download

Fatal error when trying to run the Gem example

I have just finished installing Garfield++ by following the instructions from: http://garfieldpp.web.cern.ch/garfieldpp/getting-started/. When I try to build and run a given example following the instructions from the same website. I get an error stating:

fatal error: TApplication.h: No such file or directory
4 | #include <TApplication.h>
| ^~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/gem.dir/build.make:63: CMakeFiles/gem.dir/gem.C.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:76: CMakeFiles/gem.dir/all] Error 2
make: *** [Makefile:84: all] Error 2

How do I fix this issue? My suspicion is that perhaps I may have install ROOT incorrectly?

To install ROOT, I did the following:
1)Download root_v6.20.02.source.tar.gz
2)Extract the file using tar -xzvf root_v6.20.02.source.tar.gz root-6.20.02
3)cmake …/root-6.20.02/ -Dall=ON
4)cmake --build . – -j6

After this, I tried running root and everything seems fine.

Another thing I have noticed is that when I try to do

cmake [-DCMAKE_INSTALL_PREFIX=<installdir>] [-DWITH_DOCS=ON] [-DWITH_EXAMPLES=ON] $GARFIELD_HOME

I got an error about not being able to find this directory. Please let me know if there is anything else I need to provide to make the problem more clear. Thank you.

Hi,
the square brackets in the line
cmake [-DCMAKE_INSTALL_PREFIX=<installdir>] [-DWITH_DOCS=ON] [-DWITH_EXAMPLES=ON] $GARFIELD_HOME
are meant to indicate that the respective parameter is optional. If you are happy with the default settings you can just run
cmake $GARFIELD_HOME
which will place the install directory in $GARFIELD_HOME.

Can you delete and recreate the build folder in $GARFIELD_HOME and re-build the project (re-run the cmake and make steps)?

I still get the same error after I redo the build part.

I also tried the Drifttube example, I also get a kind of similar error. But this time it’s the TVirtual.h that is not found.

Sorry, I was a bit unclear in my first reply. After redoing cmake $GARFIELD_HOME and make, please also re-run
make install
. $GARFIELD_HOME/build/setup.sh

and re-build the GEM example application (delete and recreate the build folder).

I did exactly that and still got the same error.

Try (in case of problems, inspect the three created β€œ*.out.txt” files):

# ... assuming you are using a bash like shell ...
source /full/path/to/your/root/bin/thisroot.sh # setup your ROOT
export GARFIELD_HOME=${PWD}/garfieldpp # where to build Garfield++
rm -rf ${GARFIELD_HOME} # make sure you start with an empty directory
git clone https://gitlab.cern.ch/garfield/garfieldpp.git ${GARFIELD_HOME}
cd ${GARFIELD_HOME}
mkdir build
cd build
cmake -DWITH_EXAMPLES=ON ${GARFIELD_HOME} 2>&1 | tee -a cmake.out.txt
make 2>&1 | tee -a make.out.txt
make install 2>&1 | tee -a make.install.out.txt
# ls -al Examples/Gem # "gem" should be there

If you want to build the Gem example in another directory, try (in case of problems, inspect the two created β€œ*.out.txt” files):

# ... assuming you are using a bash like shell ...
source /full/path/to/your/root/bin/thisroot.sh # setup your ROOT
# export GARFIELD_HOME=/full/path/to/your/garfieldpp # where it was built
source ${GARFIELD_HOME}/build/setup.sh # setup your Garfield++
# cd /full/path/to/where/you/want/to/build/it
rm -rf Gem # cleanup
cp -a ${GARFIELD_HOME}/Examples/Gem ./
cd Gem
mkdir build
cd build
cmake ../ 2>&1 | tee -a cmake.out.txt
make 2>&1 | tee -a make.out.txt
# ls -al # "gem" should be there
1 Like

Thank you for your reply. This seems to fix the problem. However, it does not work if I copy the Gem directory to some local directory and then try to cmake and make. I think I have found the solution. When I do cmake for garfield, I added in two more options -DROOT_INSTALL_DIR=/where/root/include/is/include and -DROOT_LIBRARY_DIR=/where/root/lib/is/lib. This solution completely fixes my issue

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.