# Fatal error: TRandom3.h: No such file or directory #include \<TRandom3.h\>

**URL:** <https://root-forum.cern.ch/t/fatal-error-trandom3-h-no-such-file-or-directory-include-trandom3-h/26128>\
**Category:** ROOT\
**Created:** [September 5, 2017, 9:44pm UTC](https://root-forum.cern.ch/t/fatal-error-trandom3-h-no-such-file-or-directory-include-trandom3-h/26128 "2017-09-05T21:44:29Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![ivancovish](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ivancovish/32/13585_2.png) [@ivancovish](https://root-forum.cern.ch/u/ivancovish)\
**Post date:** [September 5, 2017, 9:44pm UTC](https://root-forum.cern.ch/t/fatal-error-trandom3-h-no-such-file-or-directory-include-trandom3-h/26128/1 "2017-09-05T21:44:29Z")

</div>

I am working in geant4 with root.  
how I can solve this problem?

```auto
...
localhost.localdomain:/build < 5 >make
Scanning dependencies of target TPC-MC
[5%] Building CXX object CMakeFiles/TPC-MC.dir/TPC-MC.cc.o
In file included from /home/local1/Desktop/G4argon/TPC-Simulation/TPC-MC.cc:44::
/home/local1/Desktop/G4argon/TPC-Simulation/include/TPCPrimaryGeneratorAction.hh:10:22: fatal error: TRandom3.h: No such file or directory
 #include <TRandom3.h>

```

it only contained a ‘‘Makefile’’, I had to create a new CMakeFile.txt

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [September 5, 2017, 9:58pm UTC](https://root-forum.cern.ch/t/fatal-error-trandom3-h-no-such-file-or-directory-include-trandom3-h/26128/2 "2017-09-05T21:58:42Z")

</div>

I assume you are trying to link ROOT libraries into your Geant4 project.

What does your `CMakeLists.txt` look like? Did you appropriately update the search paths for include files?

Have you looked at this [example](https://root.cern.ch/how/integrate-root-my-project-cmake)?

Also just as an FYI here is how to post code snippets, including errors:

> [@Getting the same histograms after cuts](https://root-forum.cern.ch/t/getting-the-same-histograms-after-cuts/24719/2):
>
> Remark on the way to post code snippets: When you post pieces of code on the forum enclose it with ``` . That makes your post much more readable (I systematically edit your posts that way) . So do: ``` // this is a C++ piece of code. ``` And it will display as: // this is a C++ piece of code.

---

<div class="post-metadata">

**Author:** ![ivancovish](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ivancovish/32/13585_2.png) [@ivancovish](https://root-forum.cern.ch/u/ivancovish)\
**Post date:** [September 7, 2017, 4:36am UTC](https://root-forum.cern.ch/t/fatal-error-trandom3-h-no-such-file-or-directory-include-trandom3-h/26128/3 "2017-09-07T04:36:51Z")

</div>

Thanks for answering me.  
Well, I am new in this forum and I need to learn, I’ve tried working with this CMakeFile.txt.

[CMakeLists.txt](https://root-forum.cern.ch/uploads/default/original/2X/a/a3cc79abf69554a6fd76ee6eeabe0c11181f457d.txt) (3.6 KB)

I am not sure if my file was uploaded.

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [September 7, 2017, 1:45pm UTC](https://root-forum.cern.ch/t/fatal-error-trandom3-h-no-such-file-or-directory-include-trandom3-h/26128/4 "2017-09-07T13:45:46Z")

</div>

I think you problem is with the if statements. You are not indicating the variables correctly. The following should work:

```auto
if(${ROOT_FOUND})
   message(STATUS "ROOT was found!")
endif(${ROOT_FOUND})

```

---

<div class="post-metadata">

**Author:** ![ivancovish](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ivancovish/32/13585_2.png) [@ivancovish](https://root-forum.cern.ch/u/ivancovish)\
**Post date:** [September 8, 2017, 8:18pm UTC](https://root-forum.cern.ch/t/fatal-error-trandom3-h-no-such-file-or-directory-include-trandom3-h/26128/5 "2017-09-08T20:18:17Z")

</div>

Thank you. I was successful with your suggestion now I have another type of error.  
…  
localhost.localdomain:/build \< 9 \>cmake -DGeant4\_DIR=/usr/local/geant4.10.02.p02 /home/local1/Desktop/G4argon/TPC-Simulation/  
– Found ROOT 6.06/02 in /usr/local/root/6.06.02  
– Configuring done  
– Generating done  
– Build files have been written to: /home/local1/Desktop/G4argon/TPC-Simulation/build  
localhost.localdomain:/build \< 10 \>make  
[5%] Building CXX object CMakeFiles/TPC-MC.dir/src/TPCDetectorConstruction.cc.o  
/home/local1/Desktop/G4argon/TPC-Simulation/src/TPCDetectorConstruction.cc: In member function ‘void TPCDetectorConstruction::DefineGeometryParameters()’:  
/home/local1/Desktop/G4argon/TPC-Simulation/src/TPCDetectorConstruction.cc:571:18: warning: unused variable ‘dLXeLevelZeroOffset’ [-Wunused-variable]  
const G4double dLXeLevelZeroOffset =GetGeometryParameter(“LXeLevelZeroOffset”);  
^  
/home/local1/Desktop/G4argon/TPC-Simulation/src/TPCDetectorConstruction.cc: In member function ‘void TPCDetectorConstruction::ConstructOuterCryostat()’:  
/home/local1/Desktop/G4argon/TPC-Simulation/src/TPCDetectorConstruction.cc:677:69: warning: ISO C++ forbids variable length array ‘pdOuterCryostatBoreFlangeZ’ [-Wvla]  
G4double pdOuterCryostatBoreFlangeZ[dOuterCryostatBoreFlangeNumber];  
…

---

<div class="post-metadata">

**Author:** ![ksmith](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ksmith/32/12567_2.png) [@ksmith](https://root-forum.cern.ch/u/ksmith)\
**Post date:** [September 8, 2017, 8:59pm UTC](https://root-forum.cern.ch/t/fatal-error-trandom3-h-no-such-file-or-directory-include-trandom3-h/26128/6 "2017-09-08T20:59:58Z")

</div>

I assume you are asking about the following:

```auto
/home/local1/Desktop/G4argon/TPC-Simulation/src/TPCDetectorConstruction.cc:677:69: warning: ISO C++ forbids variable length array ‘pdOuterCryostatBoreFlangeZ’ [-Wvla]

```

The following is no longer permitted:

```auto
int len = 5;
double array[len];

```

Instead you need to make `len` a `const`:

```auto
const int len = 5;
double array[len];

```

or use a dynamic c array:

```auto
int len = 5;
double *array = new double[len];
//Remember to call delete!

```

or preferably use a stl array container:

```auto
int len = 5;
std::array<double, len> array;

```

---

<div class="post-metadata">

**Author:** ![ivancovish](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/ivancovish/32/13585_2.png) [@ivancovish](https://root-forum.cern.ch/u/ivancovish)\
**Post date:** [September 10, 2017, 9:02pm UTC](https://root-forum.cern.ch/t/fatal-error-trandom3-h-no-such-file-or-directory-include-trandom3-h/26128/7 "2017-09-10T21:02:46Z")

</div>

Hi.  
thanks for your suggestion I understand.  
…  
const G4int dOuterCryostatBoreFlangeNumber = GetGeometryParameter(“OuterCryostatBoreFlangeNumber”);

G4double pdOuterCryostatBoreFlangeZ[dOuterCryostatBoreFlangeNumber];

for(int i = 0; i \< dOuterCryostatBoreFlangeNumber; i++)  
…  
But, I still have errors.  
With ‘’ … warning: unused variable …’’ as well.

if you want to see the complete code. [https://github.com/ivancovish/TPC-mc](https://github.com/ivancovish/TPC-mc)

---

<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:** [September 24, 2017, 9:02pm UTC](https://root-forum.cern.ch/t/fatal-error-trandom3-h-no-such-file-or-directory-include-trandom3-h/26128/8 "2017-09-24T21:02:46Z")

</div>

Closed on September 24, 2017, 9:02pm UTC

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