# Errors compiling with g++

**URL:** <https://root-forum.cern.ch/t/errors-compiling-with-g/31527>\
**Category:** Newbie\
**Tags:** root\
**Created:** [November 9, 2018, 9:27pm UTC](https://root-forum.cern.ch/t/errors-compiling-with-g/31527 "2018-11-09T21:27:09Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![tboone42](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tboone42/32/29222_2.png) [@tboone42](https://root-forum.cern.ch/u/tboone42)\
**Post date:** [November 9, 2018, 9:27pm UTC](https://root-forum.cern.ch/t/errors-compiling-with-g/31527/1 "2018-11-09T21:27:09Z")

</div>

Hi-

I’m trying to compile a file with root libraries as well as c++ and ZeroMQ functions in the include statements. Here’s a list of my #include-s:

```auto
#include </path/to/file/zmq.hpp>
#include <iostream>
#include <string>
#include <unistd.h>
#include <errno.h>
#include <sstream>
#include <vector>
#include <errno.h>
#include <fstream>
#include <sys/timeb.h>
#include <sstream>
#include <sys/stat.h>
#include <fcntl.h>
#include <sys/types.h>
#include <stdlib.h>
#include <stdio.h>

#include <TROOT.h>
#include <TChain.h>
#include <TFile.h>
#include <TH1F.h>
#include <TH2.h>
#include <TStyle.h>
#include <TCanvas.h>
#include <TSpectrum.h>
#include <TPaveText.h>
#include <TSystem.h>
#include <TF1.h>
#include <TMath.h>
#include <TImage.h>
#include <TGraph.h>
#include <TGraphErrors.h>
#include <TLegend.h>
#include <TLegendEntry.h>

```

My compile statement looks like:

```auto
g++ `root-config --cflags --glibs` get_FEB_data.cc -o root_test -lzmq -std=c++11

```

When I do this, I get these errors:

```auto
/tmp/ccZKmDkm.o: In function `__static_initialization_and_destruction_0(int, int)':
get_FEB_data.cc:(.text+0x523): undefined reference to `TVersionCheck::TVersionCheck(int)'
/tmp/ccZKmDkm.o: In function `TCanvasImp::IsA() const':
get_FEB_data.cc:(.text._ZNK10TCanvasImp3IsAEv[_ZNK10TCanvasImp3IsAEv]+0xd): undefined reference to `TCanvasImp::Class()'
/tmp/ccZKmDkm.o: In function `TCanvasImp::ShowMembers(TMemberInspector&) const':
get_FEB_data.cc:(.text._ZNK10TCanvasImp11ShowMembersER16TMemberInspector[_ZNK10TCanvasImp11ShowMembersER16TMemberInspector]+0x11): undefined reference to `TCanvasImp::Class()'
get_FEB_data.cc:(.text._ZNK10TCanvasImp11ShowMembersER16TMemberInspector[_ZNK10TCanvasImp11ShowMembersER16TMemberInspector]+0x27): undefined reference to `ROOT::Class_ShowMembers(TClass*, void const*, TMemberInspector&)'
/tmp/ccZKmDkm.o:(.rodata._ZTV10TCanvasImp[_ZTV10TCanvasImp]+0x100): undefined reference to `TCanvasImp::Streamer(TBuffer&)'
collect2: error: ld returned 1 exit status

```

I’ve tried commenting out TCanvas for now to get rid of those errors, but the TVersionCheck error remains as long as I have any ROOT functions in the include statements. Any help would be greatly appreciated!

---

<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:** [November 9, 2018, 9:39pm UTC](https://root-forum.cern.ch/t/errors-compiling-with-g/31527/2 "2018-11-09T21:39:48Z")

</div>

```auto
`root-config --cxx --cflags` -std=c++11 -o root_test get_FEB_data.cc `root-config --libs` -lzmq

```

BTW. When you post “source code” or “output” here, do remember to enclose them into two lines which contain just three characters ``` (see how your post has been edited above).

---

<div class="post-metadata">

**Author:** ![tboone42](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tboone42/32/29222_2.png) [@tboone42](https://root-forum.cern.ch/u/tboone42)\
**Post date:** [November 9, 2018, 9:48pm UTC](https://root-forum.cern.ch/t/errors-compiling-with-g/31527/3 "2018-11-09T21:48:53Z")

</div>

Thanks so much! Though now I have a different issue. I’ve done the compilation you’ve suggested, i.e.

`g++ `root-config --cxx --cflags` -std=c++11 -o root_test get_FEB_data.cc `root-config --libs` -lzmq`

Now I’m getting this error:

`g++: error: c++: No such file or directory`

---

<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:** [November 9, 2018, 11:25pm UTC](https://root-forum.cern.ch/t/errors-compiling-with-g/31527/4 "2018-11-09T23:25:24Z")

</div>

Where do you see “g++” in my previous post?

---

<div class="post-metadata">

**Author:** ![tboone42](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/tboone42/32/29222_2.png) [@tboone42](https://root-forum.cern.ch/u/tboone42)\
**Post date:** [November 9, 2018, 11:27pm UTC](https://root-forum.cern.ch/t/errors-compiling-with-g/31527/5 "2018-11-09T23:27:28Z")

</div>

Oh! Okay. I assumed that was implied, I didn’t realize I could compile without it. Apologies, I’m not familiar with the ins and outs of all of it. It compiled, though! Thanks for your help!
