# Garfield++ installation, garfroot.C

**URL:** <https://root-forum.cern.ch/t/garfield-installation-garfroot-c/15393>\
**Category:** Garfield++\
**Created:** [December 19, 2012, 11:59am UTC](https://root-forum.cern.ch/t/garfield-installation-garfroot-c/15393 "2012-12-19T11:59:50Z")\
**Posts on this page:** 1\
**Showing post:** 6

<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:** [December 19, 2012, 3:06pm UTC](https://root-forum.cern.ch/t/garfield-installation-garfroot-c/15393/6 "2012-12-19T15:06:13Z")

</div>

Try:

```auto
OBJDIR = $(GARFIELD_HOME)/Object
SRCDIR = $(GARFIELD_HOME)/Source
INCDIR = $(GARFIELD_HOME)/Include
HEEDDIR = $(GARFIELD_HOME)/Heed
LIBDIR = $(GARFIELD_HOME)/Library

# Compiler (and Linker)
CXX = `root-config --cxx`

# Compiler (and Linker) flags
CXXFLAGS = `root-config --cflags`
CXXFLAGS += -I$(INCDIR) -I$(HEEDDIR)
# Code Generation and Optimization flags
CXXFLAGS += -fno-common -fPIC -O3
# Warning flags
CXXFLAGS += -W -Wall -Wextra -Wno-long-long
# Debug flags
CXXFLAGS += -g

# Libraries (note: the order matters)
LDLIBS = -L$(LIBDIR) -Wl,--whole-archive -lGarfield -Wl,--no-whole-archive
# Fortran libraries
LDLIBS += -lgfortran
# ROOT libraries
LDLIBS += `root-config --evelibs`

garfroot: garfroot.C
	$(CXX) $(CXXFLAGS) -o $@ $^ $(LDLIBS)

```

---

_[View the full topic](https://root-forum.cern.ch/t/garfield-installation-garfroot-c/15393)._
