# How do i run .C file importing .hh from garfield?

**URL:** <https://root-forum.cern.ch/t/how-do-i-run-c-file-importing-hh-from-garfield/48403>\
**Category:** Garfield++\
**Created:** [January 16, 2022, 1:39am UTC](https://root-forum.cern.ch/t/how-do-i-run-c-file-importing-hh-from-garfield/48403 "2022-01-16T01:39:01Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lucas\_Santos\_Sousa](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/lucas_santos_sousa/32/28320_2.png) [@Lucas\_Santos\_Sousa](https://root-forum.cern.ch/u/Lucas_Santos_Sousa)\
**Post date:** [January 16, 2022, 1:39am UTC](https://root-forum.cern.ch/t/how-do-i-run-c-file-importing-hh-from-garfield/48403/1 "2022-01-16T01:39:02Z")

</div>

I want to generate a executable from a gas file that i have writting.

```auto
#include <iostream>

#include "Garfield/MediumMagboltz.hh"
#include "Garfield/FundamentalConstants.hh"

using namespace Garfield;

int main(int argc, char * argv[]) {

  const double pressure = 1 * AtmosphericPressure;
  const double temperature = 300;
 
  // Setup the gas.
  MediumMagboltz gas;
  gas.SetComposition("Neonio", 100);
  gas.SetTemperature(temperature);
  gas.SetPressure(pressure);

  // Set the field range to be covered by the gas table. 
  const size_t nE = 20;
  const double emin = 1;
  const double emax = 100000.;
  // Flag to request logarithmic spacing.
  constexpr bool useLog = true;
  gas.SetFieldGrid(emin, emax, nE, useLog); 

  const int ncoll = 10;
  // Run Magboltz to generate the gas table.
  gas.GenerateGasTable(ncoll);
  // Save the table. 
  gas.WriteGasFile("Neonio");

}

```

The problem is that when i type gcc gas.C, the files from garfield can’t be located.  
I think i could try to write a cmake files that links the necessary informations so that all files can be located, but i am questioning myself if there is not a easier way to do it?

---

<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:** [January 16, 2022, 11:31am UTC](https://root-forum.cern.ch/t/how-do-i-run-c-file-importing-hh-from-garfield/48403/2 "2022-01-16T11:31:52Z")

</div>

Hi,  
in theory you could write directly a `makefile` to compile and link your program. But I really think it’s easier to use CMake.  
You can use the `CMakeLists.txt` in one of the examples as a template, for instance [this one](https://gitlab.cern.ch/garfield/garfieldpp/-/blob/master/Examples/GasFile/CMakeLists.txt).

---

<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:** [January 30, 2022, 11:32am UTC](https://root-forum.cern.ch/t/how-do-i-run-c-file-importing-hh-from-garfield/48403/3 "2022-01-30T11:32:44Z")

</div>

Closed on January 30, 2022, 11:32am UTC

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