# Undefined reference to \`TRandom3::Rndm(int)\` and \`\_gfortran\_…\` symbols

**URL:** <https://root-forum.cern.ch/t/undefined-reference-to-trandom3-rndm-int-and-gfortran-symbols/19663>\
**Category:** Garfield++\
**Created:** [August 9, 2015, 4:26pm UTC](https://root-forum.cern.ch/t/undefined-reference-to-trandom3-rndm-int-and-gfortran-symbols/19663 "2015-08-09T16:26:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![elia](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/278dde/32.png) [@elia](https://root-forum.cern.ch/u/elia)\
**Post date:** [August 9, 2015, 4:26pm UTC](https://root-forum.cern.ch/t/undefined-reference-to-trandom3-rndm-int-and-gfortran-symbols/19663/1 "2015-08-09T16:26:56Z")

</div>

I’m trying to compile an example program to understand how garfield++ works (that I want to use to simulate a drift tube). I’ve just installed garfield++ and I’ve downloaded the example program at the bottom of this page [garfieldpp.web.cern.ch/garfieldpp/examples/tube/](http://garfieldpp.web.cern.ch/garfieldpp/examples/tube/) then I’ve done the “make” command but I’ve received the following errors:

`roberto@roberto-HP-Pavilion-dv6-Notebook-PC:~/Scrivania/Garfield$ make
g++ -Wall -Wextra -Wno-long-long `root-config --cflags` -O3 -fno-common -c -I/home/roberto/garfield/Include -I/home/roberto/garfield/Heed gasfile.C
gasfile.C:12:5: warning: unused parameter ‘argc’ [-Wunused-parameter]
 int main(int argc, char * argv[]) {
     ^
gasfile.C:12:5: warning: unused parameter ‘argv’ [-Wunused-parameter]
g++ -o gasfile gasfile.o `root-config --glibs` -lGeom -lgfortran -lm -L/home/roberto/garfield/Library -lGarfield
/home/roberto/garfield/Library/libGarfield.a(Medium.o): nella funzione "Garfield::Medium::GetElectronMomentum(double, double&, double&, double&, int&)":
Medium.cc:(.text+0xf0b4): riferimento non definito a "TRandom3::Rndm(int)"
Medium.cc:(.text+0xf0fb): riferimento non definito a "TRandom3::Rndm(int)"
/home/roberto/garfield/Library/libGarfield.a(Medium.o): nella funzione "Garfield::Medium::GetElectronCollision(double, int&, int&, double&, double&, double&, double&, int&, int&, int&)":
Medium.cc:(.text+0xf1ea): riferimento non definito a "TRandom3::Rndm(int)"
Medium.cc:(.text+0xf231): riferimento non definito a "TRandom3::Rndm(int)"
/home/roberto/garfield/Library/libGarfield.a(MediumMagboltz.o): nella funzione "Garfield::MediumMagboltz::ComputePhotonCollisionTable(bool)":
MediumMagboltz.cc:(.text+0x4cd1): riferimento non definito a "TMath::Voigt(double, double, double, int)"
/home/roberto/garfield/Library/libGarfield.a(MediumMagboltz.o): nella funzione "Garfield::MediumMagboltz::GetPhotonCollisionRate(double const&)":
MediumMagboltz.cc:(.text+0x24913): riferimento non definito a "TMath::Voigt(double, double, double, int)"
/home/roberto/garfield/Library/libGarfield.a(MediumMagboltz.o): nella funzione "Garfield::MediumMagboltz::ComputeDeexcitationInternal(int, int&)":
MediumMagboltz.cc:(.text+0x25319): riferimento non definito a "TRandom3::Rndm(int)"
MediumMagboltz.cc:(.text+0x2533e): riferimento non definito a "TRandom3::Rndm(int)"
MediumMagboltz.cc:(.text+0x25387): riferimento non definito a "TRandom3::Rndm(int)"
MediumMagboltz.cc:(.text+0x255da): riferimento non definito a "TRandom3::Rndm(int)"
MediumMagboltz.cc:(.text+0x256ca): riferimento non definito a "TRandom3::Rndm(int)"
/home/roberto/garfield/Library/libGarfield.a(MediumMagboltz.o):MediumMagboltz.cc:(.text+0x25746): seguono ulteriori riferimenti non definiti a "TRandom3::Rndm(int)"
/home/roberto/garfield/Library/libGarfield.a(MediumMagboltz.o): nella funzione "Garfield::MediumMagboltz::GetPhotonCollision(double, int&, int&, double&, double&, int&, double&)":
MediumMagboltz.cc:(.text+0x26fa8): riferimento non definito a "TMath::Voigt(double, double, double, int)"
MediumMagboltz.cc:(.text+0x2703d): riferimento non definito a "TRandom3::Rndm(int)"
MediumMagboltz.cc:(.text+0x270ef): riferimento non definito a "TRandom3::Rndm(int)"
MediumMagboltz.cc:(.text+0x2730d): riferimento non definito a "TRandom3::Rndm(int)"
/home/roberto/garfield/Library/libGarfield.a(RandomEngineRoot.o): nella funzione "Garfield::RandomEngineRoot::RandomEngineRoot()":
RandomEngineRoot.cc:(.text+0x2c): riferimento non definito a "TRandom3::TRandom3(unsigned int)"
RandomEngineRoot.cc:(.text+0xbe): riferimento non definito a "TRandom3::~TRandom3()"
/home/roberto/garfield/Library/libGarfield.a(RandomEngineRoot.o): nella funzione "Garfield::RandomEngineRoot::~RandomEngineRoot()":
RandomEngineRoot.cc:(.text+0xf6): riferimento non definito a "TRandom3::~TRandom3()"
/home/roberto/garfield/Library/libGarfield.a(RandomEngineRoot.o): nella funzione "Garfield::RandomEngineRoot::Seed(unsigned int)":
RandomEngineRoot.cc:(.text+0x175): riferimento non definito a "TRandom3::SetSeed(unsigned int)"
/home/roberto/garfield/Library/libGarfield.a(RandomEngineRoot.o): nella funzione "Garfield::RandomEngineRoot::Draw()":
RandomEngineRoot.cc:(.text._ZN8Garfield16RandomEngineRoot4DrawEv[_ZN8Garfield16RandomEngineRoot4DrawEv]+0x12): riferimento non definito a "TRandom3::Rndm(int)"
/home/roberto/garfield/Library/libGarfield.a(magboltz.o): nella funzione "master.0.rm48_":
magboltz-9.01.f:(.text+0x29f): riferimento non definito a "_gfortran_st_write"
magboltz-9.01.f:(.text+0x2b3): riferimento non definito a "_gfortran_transfer_character_write"
magboltz-9.01.f:(.text+0x2c7): riferimento non definito a "_gfortran_transfer_integer_write"
magboltz-9.01.f:(.text+0x2db): riferimento non definito a "_gfortran_transfer_integer_write"
magboltz-9.01.f:(.text+0x2ef): riferimento non definito a "_gfortran_transfer_integer_write"`

Where “riferimento non definito” is the Italian for “undefined reference to”. I can’t understand the problem because in the Makefile there is a link to gfortran and to the root’s libraries.

---

<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:** [August 9, 2015, 4:31pm UTC](https://root-forum.cern.ch/t/undefined-reference-to-trandom3-rndm-int-and-gfortran-symbols/19663/2 "2015-08-09T16:31:20Z")

</div>

Try: ``root-config --cxx --cflags` -o gasfile gasfile.o -L/home/roberto/garfield/Library -lGarfield `root-config --glibs` -lGeom -lgfortran -lm`

---

<div class="post-metadata">

**Author:** ![elia](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/278dde/32.png) [@elia](https://root-forum.cern.ch/u/elia)\
**Post date:** [August 10, 2015, 9:36am UTC](https://root-forum.cern.ch/t/undefined-reference-to-trandom3-rndm-int-and-gfortran-symbols/19663/3 "2015-08-10T09:36:54Z")

</div>

Thanks for the answer. If I do:

`roberto@roberto-HP-Pavilion-dv6-Notebook-PC:~/Scrivania/Garfield$ `root-config --cxx --cflags` -o gasfile gasfile.C -L/home/roberto/garfield/Library -lGarfield `root-config --glibs` -lGeom -lgfortran -lm
gasfile.C:7:29: fatal error: MediumMagboltz.hh: No such file or directory
 #include "MediumMagboltz.hh"
                             ^
compilation terminated.`

Because MediumMagboltz.hh is in /home/roberto/garfield/Include/MediumMagboltz.hh, so I do:

`roberto@roberto-HP-Pavilion-dv6-Notebook-PC:~/Scrivania/Garfield$ `root-config --cxx --cflags` -o gasfile gasfile.C -L/home/roberto/garfield/Library -L/home/roberto/garfield/Include -L/home/roberto/garfield/Heed -lGarfield `root-config --glibs` -lGeom -lgfortran -lm
gasfile.C:7:29: fatal error: MediumMagboltz.hh: No such file or directory
 #include "MediumMagboltz.hh"
                             ^
compilation terminated.
`  
But I get the same error.  
I was using the following makefile -\> [garfieldpp.web.cern.ch/garfieldp … e/makefile](http://garfieldpp.web.cern.ch/garfieldpp/examples/tube/makefile)

---

<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:** [August 10, 2015, 9:42am UTC](https://root-forum.cern.ch/t/undefined-reference-to-trandom3-rndm-int-and-gfortran-symbols/19663/4 "2015-08-10T09:42:07Z")

</div>

My fix was not replacing the compiler command line, but the linker one (actually, when linking, instead of “`root-config --cxx --cflags`” you can use “`root-config --cxx --ldflags`”).  
Anyhow, try the attached “makefile.txt”.  
[makefile.txt](https://root-forum.cern.ch/uploads/default/original/2X/8/8936d486bbddf4656b7e05259148dea761ece966.txt) (558 Bytes)

---

<div class="post-metadata">

**Author:** ![elia](https://root-forum.cern.ch/letter_avatar_proxy/v4/letter/e/278dde/32.png) [@elia](https://root-forum.cern.ch/u/elia)\
**Post date:** [August 10, 2015, 1:26pm UTC](https://root-forum.cern.ch/t/undefined-reference-to-trandom3-rndm-int-and-gfortran-symbols/19663/5 "2015-08-10T13:26:43Z")

</div>

Thank you, now it works 😃

---

<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, 11:41am UTC](https://root-forum.cern.ch/t/undefined-reference-to-trandom3-rndm-int-and-gfortran-symbols/19663/6 "2018-06-21T11:41:00Z")

</div>

Closed on June 21, 2018, 11:41am UTC

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