# Fatal error when trying to run the Gem example

**URL:** <https://root-forum.cern.ch/t/fatal-error-when-trying-to-run-the-gem-example/39995>\
**Category:** Garfield++\
**Created:** [June 20, 2020, 6:08am UTC](https://root-forum.cern.ch/t/fatal-error-when-trying-to-run-the-gem-example/39995 "2020-06-20T06:08:47Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Khang\_Pham](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/khang_pham/32/19369_2.png) [@Khang\_Pham](https://root-forum.cern.ch/u/Khang_Pham)\
**Post date:** [June 20, 2020, 6:08am UTC](https://root-forum.cern.ch/t/fatal-error-when-trying-to-run-the-gem-example/39995/1 "2020-06-20T06:08:47Z")

</div>

I have just finished installing Garfield++ by following the instructions from: [http://garfieldpp.web.cern.ch/garfieldpp/getting-started/](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

```auto
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.

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [June 20, 2020, 8:13am UTC](https://root-forum.cern.ch/t/fatal-error-when-trying-to-run-the-gem-example/39995/2 "2020-06-20T08:13:01Z")

</div>

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)?

---

<div class="post-metadata">

**Author:** ![Khang\_Pham](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/khang_pham/32/19369_2.png) [@Khang\_Pham](https://root-forum.cern.ch/u/Khang_Pham)\
**Post date:** [June 20, 2020, 8:52am UTC](https://root-forum.cern.ch/t/fatal-error-when-trying-to-run-the-gem-example/39995/3 "2020-06-20T08:52:08Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![Khang\_Pham](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/khang_pham/32/19369_2.png) [@Khang\_Pham](https://root-forum.cern.ch/u/Khang_Pham)\
**Post date:** [June 20, 2020, 9:18am UTC](https://root-forum.cern.ch/t/fatal-error-when-trying-to-run-the-gem-example/39995/4 "2020-06-20T09:18:20Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![hschindl](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/h/977dab/32.png) [@hschindl](https://root-forum.cern.ch/u/hschindl)\
**Post date:** [June 20, 2020, 9:33am UTC](https://root-forum.cern.ch/t/fatal-error-when-trying-to-run-the-gem-example/39995/5 "2020-06-20T09:33:25Z")

</div>

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/setupGarfield.sh`

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

---

<div class="post-metadata">

**Author:** ![Khang\_Pham](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/khang_pham/32/19369_2.png) [@Khang\_Pham](https://root-forum.cern.ch/u/Khang_Pham)\
**Post date:** [June 20, 2020, 9:38am UTC](https://root-forum.cern.ch/t/fatal-error-when-trying-to-run-the-gem-example/39995/6 "2020-06-20T09:38:56Z")

</div>

I did exactly that and still got the same error.

---

<div class="post-metadata">

**Author:** ![Wile\_E\_Coyote](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/wile_e_coyote/32/12417_2.png) [@Wile\_E\_Coyote](https://root-forum.cern.ch/u/Wile_E_Coyote)\
**Post date:** [June 20, 2020, 4:10pm UTC](https://root-forum.cern.ch/t/fatal-error-when-trying-to-run-the-gem-example/39995/7 "2020-06-20T16:10:58Z")

</div>

Below, you can find simple instructions on how to build Garfield++ (with examples) from scratch.  
Try (in case of problems, inspect the three created “`*.out.txt`” files):

```bash
# ... 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 --depth=1 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
# source ./setupGarfield.sh # setup this Garfield++ (if you want to use it now)

```

If you want to build, e.g., the [Gem](https://gitlab.cern.ch/garfield/garfieldpp/tree/master/Examples/Gem) example in another separate directory, try (in case of problems, inspect the two created “`*.out.txt`” files):

```bash
# ... 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/setupGarfield.sh # setup your Garfield++
# cd /full/path/to/where/you/want/to/play/with/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

```

Detailed explanations can be found on the following web pages:

- [Garfield++ → Getting started](https://garfieldpp.web.cern.ch/garfieldpp/getting-started/)
- [Garfield++ → README.md](https://gitlab.cern.ch/garfield/garfieldpp/-/blob/master/README.md)

---

<div class="post-metadata">

**Author:** ![Khang\_Pham](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/khang_pham/32/19369_2.png) [@Khang\_Pham](https://root-forum.cern.ch/u/Khang_Pham)\
**Post date:** [June 21, 2020, 3:12am UTC](https://root-forum.cern.ch/t/fatal-error-when-trying-to-run-the-gem-example/39995/8 "2020-06-21T03:12:09Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![system](https://root-forum.cern.ch/uploads/default/original/3X/e/f/efe4f24398fd8ffeb76bccb6ecc46d9d9c003376.png) [@system](https://root-forum.cern.ch/u/system)\
**Post date:** [July 5, 2020, 3:38pm UTC](https://root-forum.cern.ch/t/fatal-error-when-trying-to-run-the-gem-example/39995/10 "2020-07-05T15:38:32Z")

</div>

Closed on July 5, 2020, 3:38pm UTC

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