# ROOT Garfield++ static compile

**URL:** <https://root-forum.cern.ch/t/root-garfield-static-compile/15289>\
**Category:** Garfield++\
**Created:** [November 23, 2012, 1:05pm UTC](https://root-forum.cern.ch/t/root-garfield-static-compile/15289 "2012-11-23T13:05:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrii](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/a/77aa72/32.png) [@Andrii](https://root-forum.cern.ch/u/Andrii)\
**Post date:** [November 23, 2012, 1:05pm UTC](https://root-forum.cern.ch/t/root-garfield-static-compile/15289/1 "2012-11-23T13:05:15Z")

</div>

I am trying to run my executable at Batch Farm. The problem is in shared libraries which is not possible to use in Computing Farm(there must be static executable).  
I found a reply for the same problem at : [root.cern.ch/root/roottalk/roottalk11/1244.html](http://root.cern.ch/root/roottalk/roottalk11/1244.html)  
So, I installed ROOT locally and did make static. Now I have libRoot.a ~150MB. In my makefile i do the next:

* * *

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

CXX = g++
CXXFLAGS = -g -Wall -fPIC 
LD = g++
SOFLAGS = shared

# Compiler flags
CFLAGS = -Wall -Wextra -Wno-long-long \
`root-config --cflags` \
-O3 -fno-common -c \
-I$(INCDIR) -I$(HEEDDIR)

# Debug flags
CFLAGS += -g

LDFLAGS = -lRoot -lm `root-config --glibs` -lGeom -static -lgfortran
LDFLAGS += -L$(LIBDIR) -lGarfield -L$(ROOTSYS)/lib
#LDFLAGS += -g

gem3: gem3.C  
$(CXX) $(CFLAGS) gem3.C
$(CXX) -o gem3 gem3.o $(LDFLAGS)
rm gem3.o

```

* * *

But still have error:  
/usr/bin/ld: cannot find -lGui

Any suggestions?

---

<div class="post-metadata">

**Author:** ![honk](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/honk/32/11273_2.png) [@honk](https://root-forum.cern.ch/u/honk)\
**Post date:** [November 23, 2012, 6:02pm UTC](https://root-forum.cern.ch/t/root-garfield-static-compile/15289/2 "2012-11-23T18:02:58Z")

</div>

> [@Andrii](#):
>
> LDFLAGS = -lRoot -lm `root-config --glibs` -lGeom -static -lgfortran

“root-config --glibs” outputs LDFLAGS for dynamic linking (with shared libraries). I am not sure if you put it in there for some purpose or if it’s just a left-over, but you should take it out. -lRoot should contain all symbols you need.

---

<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:** [June 21, 2018, 2:41pm UTC](https://root-forum.cern.ch/t/root-garfield-static-compile/15289/3 "2018-06-21T14:41:05Z")

</div>

Closed on June 21, 2018, 2:41pm UTC

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