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

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

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

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.

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