Errors compiling with g++

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:

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

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

When I do this, I get these errors:

/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!

`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).

1 Like

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

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

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!