Hi, during ‘make’ a root macro, I am getting the following errors, can somebody help me to resolve these issues?
g++ -g -std=gnu++11 bin/event_io.cxx -I/opt/root/6.22.02-install/include -g -fPIC -c -o bin/event_io.o
In file included from bin/event_io.cxx:34:
bin/event_config.h:48:1: warning: ‘typedef’ was ignored in this declaration
48 | typedef struct RunHeader
| ^~~~~~~
bin/event_config.h:132:1: warning: ‘typedef’ was ignored in this declaration
132 | typedef struct message_body
| ^~~~~~~
bin/event_config.h:140:1: warning: ‘typedef’ was ignored in this declaration
140 | typedef struct message_header {
| ^~~~~~~
bin/event_config.h:151:1: warning: ‘typedef’ was ignored in this declaration
151 | typedef struct event_CAM
| ^~~~~~~
bin/event_config.h:162:1: warning: ‘typedef’ was ignored in this declaration
162 | typedef struct event_CAM1
| ^~~~~~~
bin/event_config.h:167:1: warning: ‘typedef’ was ignored in this declaration
167 | typedef struct event_CAM2
| ^~~~~~~
bin/event_config.h:172:1: warning: ‘typedef’ was ignored in this declaration
172 | typedef struct TimeStamp
| ^~~~~~~
In file included from /opt/root/6.22.02-install/include/TString.h:28,
from /opt/root/6.22.02-install/include/TNamed.h:26,
from /opt/root/6.22.02-install/include/TDirectory.h:24,
from /opt/root/6.22.02-install/include/TROOT.h:28,
from bin/event_io.h:35,
from bin/event_io.cxx:35:
/opt/root/6.22.02-install/include/ROOT/RStringView.hxx:84:17: error: expected type-specifier
84 | operator std::string_view() const { return std::string_view(fData,fLength); }
| ^~~
In file included from /opt/root/6.22.02-install/include/TNamed.h:26,
from /opt/root/6.22.02-install/include/TDirectory.h:24,
from /opt/root/6.22.02-install/include/TROOT.h:28,
from bin/event_io.h:35,
from bin/event_io.cxx:35:
/opt/root/6.22.02-install/include/TString.h:110:13: error: expected type-specifier
110 | operator std::string_view() const { return std::string_view(Data(),fExtent); }
| ^~~
/opt/root/6.22.02-install/include/TString.h:275:32: error: ‘string_view’ in namespace ‘std’ does not name a type
275 | explicit TString(const std::string_view &sub);
| ^~~~~~~~~~~
/opt/root/6.22.02-install/include/TString.h:275:27: note: ‘std::string_view’ is only available from C++17 onwards
275 | explicit TString(const std::string_view &sub);
| ^~~
/opt/root/6.22.02-install/include/TString.h:312:37: error: ‘string_view’ in namespace ‘std’ does not name a type
312 | TString &operator=(const std::string_view &s);
| ^~~~~~~~~~~
/opt/root/6.22.02-install/include/TString.h:312:32: note: ‘std::string_view’ is only available from C++17 onwards
312 | TString &operator=(const std::string_view &s);
| ^~~
/opt/root/6.22.02-install/include/TString.h:439:9: error: ‘string_view’ in namespace ‘std’ does not name a type
439 | std::string_view View() const { return std::string_view(GetPointer(),Length()); }
| ^~~~~~~~~~~
/opt/root/6.22.02-install/include/TString.h:439:4: note: ‘std::string_view’ is only available from C++17 onwards
439 | std::string_view View() const { return std::string_view(GetPointer(),Length()); }
| ^~~
In file included from /opt/root/6.22.02-install/include/TNamed.h:26,
from /opt/root/6.22.02-install/include/TDirectory.h:24,
from /opt/root/6.22.02-install/include/TROOT.h:28,
from bin/event_io.h:35,
from bin/event_io.cxx:35:
/opt/root/6.22.02-install/include/TString.h:834:53: error: ‘string_view’ in namespace ‘std’ does not name a type
834 | inline Bool_t operator==(const char *s1, const std::string_view &s2)
| ^~~~~~~~~~~
/opt/root/6.22.02-install/include/TString.h:834:48: note: ‘std::string_view’ is only available from C++17 onwards
834 | inline Bool_t operator==(const char *s1, const std::string_view &s2)
| ^~~
/opt/root/6.22.02-install/include/TString.h:834:15: error: ‘Bool_t operator==(const char*, const int&)’ must have an argument of class or enumerated type
834 | inline Bool_t operator==(const char *s1, const std::string_view &s2)
| ^~~~~~~~
/opt/root/6.22.02-install/include/TString.h:839:37: error: ‘string_view’ in namespace ‘std’ does not name a type
839 | inline Bool_t operator==(const std::string_view &s1, const char *s2)
| ^~~~~~~~~~~
/opt/root/6.22.02-install/include/TString.h:839:32: note: ‘std::string_view’ is only available from C++17 onwards
839 | inline Bool_t operator==(const std::string_view &s1, const char *s2)
| ^~~
/opt/root/6.22.02-install/include/TString.h:839:15: error: ‘Bool_t operator==(const int&, const char*)’ must have an argument of class or enumerated type
839 | inline Bool_t operator==(const std::string_view &s1, const char *s2)
| ^~~~~~~~
/opt/root/6.22.02-install/include/TString.h:852:37: error: ‘string_view’ in namespace ‘std’ does not name a type
852 | std::string printValue(const std::string_view* val);
| ^~~~~~~~~~~
/opt/root/6.22.02-install/include/TString.h:852:32: note: ‘std::string_view’ is only available from C++17 onwards
852 | std::string printValue(const std::string_view* val);
| ^~~
In file included from bin/event_io.h:37,
from bin/event_io.cxx:35:
/opt/root/6.22.02-install/include/TFile.h:326:45: error: ‘std::string_view’ has not been declared
326 | static Bool_t SetCacheFileDir(std::string_view cacheDir, Bool_t operateDisconnected = kTRUE,
| ^~~~~~~~~~~
/opt/root/6.22.02-install/include/TFile.h: In static member function ‘static Bool_t TFile::SetCacheFileDir(ROOT::Internal::TStringView, Bool_t, Bool_t)’:
/opt/root/6.22.02-install/include/TFile.h:325:36: error: ‘string_view’ is not a member of ‘std’
325 | { return SetCacheFileDir(std::string_view(cacheDir), operateDisconnected, forceCacheread); }
| ^~~~~~~~~~~
/opt/root/6.22.02-install/include/TFile.h:325:36: note: ‘std::string_view’ is only available from C++17 onwards
make: *** [Makefile:102: bin/event_io.o] Error 1
Looks like you try to mix C++ standards.
Try (note “-std=...
”): root-config --cflags
My make file is like this, where I have to replace these things, which you have suggested,…
#########################################################################
# Makefile for the ROOT test programs.
# This Makefile shows nicely how to compile and link applications
# using the ROOT libraries on all supported platforms.
#
# Copyright (c) 2000 Rene Brun and Fons Rademakers
#
# Author: Fons Rademakers, 29/2/2000
# Common directories for links to all include files and all shared libaries.
ROOTLIBS := $(shell root-config --libs)
ROOTGLIBS := $(shell root-config --glibs)
ROOTINCS = -I$(shell root-config --incdir)
INCLUDES = $(ROOTINCS)
LIBS = $(ROOTLIBS)
GLIBS = $(ROOTGLIBS) $(SYSXLIBS)
ROOTVER := $(shell root-config --version)
ROOTMAJORVER := $(shell echo $(ROOTVER) | cut -f1 -d.)
CXXFLAGS = -g
ifeq ($(ROOTMAJORVER),6)
CXXFLAGS += -std=gnu++11
endif
ObjSuf = o
SrcSuf = cxx
ExeSuf =
%O = %.$(ObjSuf)
%S = %.$(SrcSuf)
% = %$(ExeSuf)
conversion/event_to_L2S = conversion/event_to_L2.$(SrcSuf)
conversion/event_to_L2 = conversion/event_to_L2$(ExeSuf)
conversion/event_ioO = conversion/event_io.$(ObjSuf)
conversion/event_ioS = conversion/event_io.$(SrcSuf)
bin/event_to_L2S = bin/event_to_L2.$(SrcSuf)
bin/event_to_L2 = bin/event_to_L2$(ExeSuf)
bin/event_ioO = bin/event_io.$(ObjSuf)
bin/event_ioS = bin/event_io.$(SrcSuf)
bin/mace_analysisS=bin/mace_analysis.$(SrcSuf)
bin/mace_analysis=bin/mace_analysis$(ExeSuf)
bin/mace_telemetryS=bin/mace_telemetry.$(SrcSuf)
bin/mace_telemetry=bin/mace_telemetry$(ExeSuf)
bin/mace_telemetry_guiS=bin/mace_telemetry_gui.$(SrcSuf)
bin/mace_telemetry_gui=bin/mace_telemetry_gui$(ExeSuf)
display_events/Read_event_profileS=display_events/Read_event_profile.$(SrcSuf)
display_events/Read_event_profile=display_events/Read_event_profile$(ExeSuf)
display_calibration/Read_calibrationS=display_calibration/Read_calibration.$(SrcSuf)
display_calibration/Read_calibration=display_calibration/Read_calibration$(ExeSuf)
display_telemetry/Read_telemetryS=display_telemetry/Read_telemetry.$(SrcSuf)
display_telemetry/Read_telemetry=display_telemetry/Read_telemetry$(ExeSuf)
display_events/ReadS=display_events/Read.$(SrcSuf)
display_events/Read=display_events/Read$(ExeSuf)
utility/analyse_xfileS=utility/analyse_xfile.$(SrcSuf)
utility/analyse_xfile=utility/analyse_xfile$(ExeSuf)
lightcurve/M_lightcurveS=lightcurve/M_lightcurve.$(SrcSuf)
lightcurve/M_lightcurve=lightcurve/M_lightcurve$(ExeSuf)
bin/led_scanS=bin/led_scan.$(SrcSuf)
bin/led_scan=bin/led_scan(ExeSuf)
PROGRAMS = $(bin/event_to_L2) $(conversion/event_to_L2) $(bin/mace_analysis) $(bin/mace_telemetry) $(display_events/Read_event_profile) $(display_events/Read) $(utility/analyse_xfile) $(bin/mace_telemetry_gui) $(display_calibration/Read_calibration) $(display_telemetry/Read_telemetry)
#PROGRAMS = $(routine_to_L2) $(critical_to_L2) $(event_to_L2) $(tcu_to_L2)
#------------------------------------------------------------------------------
.SUFFIXES: .$(SrcSuf) .$(ObjSuf) .$(DllSuf)
all: $(PROGRAMS)
$(conversion/event_to_L2):$(conversion/event_to_L2S) $(conversion/event_ioO)
$(CXX) $(CXXFLAGS) $(INCLUDES) $^ $(LIBS) $(GLIBS) -o $@
@echo "$@ done"
$(bin/event_to_L2):$(bin/event_to_L2S) $(bin/event_ioO)
$(CXX) $(CXXFLAGS) $(INCLUDES) $^ $(LIBS) $(GLIBS) -o $@
@echo "$@ done"
$(telemetry_ioO) : $(telemetry_ioS) telemetry_io.h telemetry_config.h
$(CXX) $(CXXFLAGS) $(telemetry_ioS) $(INCLUDES) -g -fPIC -c -o $@
@echo "$@ done"
$(conversion/event_ioO) : $(conversion/event_ioS) conversion/event_io.h conversion/event_config.h
$(CXX) $(CXXFLAGS) $(conversion/event_ioS) $(INCLUDES) -g -fPIC -c -o $@
@echo "$@ done"
$(bin/event_ioO) : $(bin/event_ioS) bin/event_io.h bin/event_config.h
$(CXX) $(CXXFLAGS) $(bin/event_ioS) $(INCLUDES) -g -fPIC -c -o $@
@echo "$@ done"
$(bin/mace_analysis):$(bin/mace_analysisS)
$(CXX) $(CXXFLAGS) $(INCLUDES) $^ $(LIBS) $(GLIBS) -o $@
@echo "$@ done"
$(bin/mace_telemetry):$(bin/mace_telemetryS)
$(CXX) $(CXXFLAGS) $(INCLUDES) $^ $(LIBS) $(GLIBS) -o $@
@echo "$@ done"
$(bin/led_scan):$(bin/led_scanS)
$(CXX) $(CXXFLAGS) $(INCLUDES) $^ $(LIBS) $(GLIBS) -o $@
@echo "$@ done"
$(utility/analyse_xfile):$(utility/analyse_xfileS)
$(CXX) $(CXXFLAGS) $(INCLUDES) $^ $(LIBS) $(GLIBS) -o $@
@echo "$@ done"
$(lightcurve/M_lightcurve):$(lightcurve/M_lightcurveS)
$(CXX) $(CXXFLAGS) $(INCLUDES) $^ $(LIBS) $(GLIBS) -o $@
@echo "$@ done"
$(bin/mace_telemetry_gui):$(bin/mace_telemetry_guiS)
$(CXX) $(CXXFLAGS) $(INCLUDES) $^ $(LIBS) $(GLIBS) -o $@
@echo "$@ done"
$(display_events/Read_event_profile):$(display_events/Read_event_profileS)
rootcint -f display_events/MyMainFrameDict.cxx -c -p display_events/camera.h display_events/LinkDef.h
g++ -o display_events/Read_event_profile display_events/Read_event_profile.cxx display_events/MyMainFrameDict.cxx `root-config --cflags --glibs`
$(display_events/Read):$(display_events/ReadS)
rootcint -f display_events/MyMainFrameDict.cxx -c -p display_events/camera.h display_events/LinkDef.h
g++ -o display_events/Read_event_profile display_events/Read_event_profile.cxx display_events/MyMainFrameDict.cxx `root-config --cflags --glibs`
$(display_telemetry/Read_telemetry):$(display_telemetry/Read_telemetryS)
rootcint -f display_telemetry/MyMainFrameDict.cxx -c -p display_telemetry/camera.h display_telemetry/LinkDef.h
g++ -o display_telemetry/Read_telemetry display_telemetry/Read_telemetry.cxx display_events/MyMainFrameDict.cxx `root-config --cflags --glibs`
$(display_calibration/Read_calibration):$(display_calibration/Read_calibrationS)
rootcint -f display_calibration/MyMainFrameDict.cxx -c -p display_calibration/camera.h display_calibration/LinkDef.h
g++ -o display_calibration/Read_calibration display_calibration/Read_calibration.cxx display_events/MyMainFrameDict.cxx `root-config --cflags --glibs`
tt : tt.cxx $(event_ioO) $(telemetry_ioO)
$(CXX) $(CXXFLAGS) $(INCLUDES) $^ $(LIBS) $(GLIBS) -o $@
@echo "$@ done"
Read:
rootcint -f display_events/MyMainFrameDict.cxx -c -p display_events/camera.h display_events/LinkDef.h
g++ -o display_events/Read display_events/Read.cxx display_events/MyMainFrameDict.cxx `root-config --cflags --glibs`
Read_event_profile:
rootcint -f display_events/MyMainFrameDict.cxx -c -p display_events/camera.h display_events/LinkDef.h
g++ -o display_events/Read_event_profile display_events/Read_event_profile.cxx display_events/MyMainFrameDict.cxx `root-config --cflags --glibs`
Read_telemetry:
rootcint -f display_telemetry/MyMainFrameDict.cxx -c -p display_telemetry/camera.h display_telemetry/LinkDef.h
g++ -o display_telemetry/Read_telemetry display_telemetry/Read_telemetry.cxx MyMainFrameDict.cxx `root-config --cflags --glibs`
Read_calibration:
rootcint -f display_calibration/MyMainFrameDict.cxx -c -p display_calibration/camera.h display_calibration/LinkDef.h
g++ -o display_calibration/Read_calibration display_calibration/Read_calibration.cxx MyMainFrameDict.cxx `root-config --cflags --glibs`
clean:
@rm -f $(OBJS) $(telemetry_ioO) $(bin/event_ioO) $(conversion/event_ioO) $(PROGRAMS) core
distclean: clean
@rm -f $(PROGRAMS) *Dict.* *.def *.exp \
*.root *.ps *.so .def so_locations
$(%): $(%O)
$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt)$@
@echo "$@ done"
.SUFFIXES: .$(SrcSuf)
.$(SrcSuf).$(ObjSuf):
$(CXX) $(INCLUDES) $(CXXFLAGS) -c $<
Run: root-config --cflags
Maybe this helps:
CXXFLAGS += $(shell root-config --cflags)
Now, I am getting these errors:
display_calibration/Read_calibration.cxx:673:28: error: ‘setw’ was not declared in this scope; did you mean ‘getw’?
673 | outputfileLED << setw(4) << left << chlist+1 << "\t" << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << LedMean[ch] << "\t" << LedSD[ch] << "\t" << LedMean[ch]/LedMean[refencechannel] << "\n";
| ^~~~
| getw
display_calibration/Read_calibration.cxx:673:124: error: ‘setprecision’ was not declared in this scope
673 | outputfileLED << setw(4) << left << chlist+1 << "\t" << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << LedMean[ch] << "\t" << LedSD[ch] << "\t" << LedMean[ch]/LedMean[refencechannel] << "\n";
| ^~~~~~~~~~~~
display_calibration/Read_calibration.cxx:690:28: error: ‘setw’ was not declared in this scope; did you mean ‘getw’?
690 | outputfileLED << setw(4) << left << chlist+1 << "\t" << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << LedMean[ch] << "\t" << LedSD[ch] << "\t" << LedMean[ch]/LedMean[refencechannel] << "\n";
| ^~~~
| getw
display_calibration/Read_calibration.cxx:690:124: error: ‘setprecision’ was not declared in this scope
690 | outputfileLED << setw(4) << left << chlist+1 << "\t" << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << LedMean[ch] << "\t" << LedSD[ch] << "\t" << LedMean[ch]/LedMean[refencechannel] << "\n";
| ^~~~~~~~~~~~
display_calibration/Read_calibration.cxx:703:33: error: ‘setw’ was not declared in this scope; did you mean ‘getw’?
703 | if(lflag==1) outputfileLED << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << LedMean[ch] << "\t" << LedSD[ch] << "\t" << LedMean[ch]/LedMean[refencechannel] << "\n";
| ^~~~
| getw
display_calibration/Read_calibration.cxx:703:89: error: ‘setprecision’ was not declared in this scope
703 | if(lflag==1) outputfileLED << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << LedMean[ch] << "\t" << LedSD[ch] << "\t" << LedMean[ch]/LedMean[refencechannel] << "\n";
| ^~~~~~~~~~~~
display_calibration/Read_calibration.cxx:704:39: error: ‘setw’ was not declared in this scope; did you mean ‘getw’?
704 | if(sflag==1) outputfileSKY << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << SkyMean[ch] << "\t" << SkySD[ch] << "\n";
| ^~~~
| getw
display_calibration/Read_calibration.cxx:704:95: error: ‘setprecision’ was not declared in this scope
704 | if(sflag==1) outputfileSKY << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << SkyMean[ch] << "\t" << SkySD[ch] << "\n";
Sir, I am again getting these errors, …
display_calibration/Read_calibration.cxx:673:28: error: ‘setw’ was not declared in this scope; did you mean ‘getw’?
673 | outputfileLED << setw(4) << left << chlist+1 << "\t" << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << LedMean[ch] << "\t" << LedSD[ch] << "\t" << LedMean[ch]/LedMean[refencechannel] << "\n";
| ^~~~
| getw
display_calibration/Read_calibration.cxx:673:124: error: ‘setprecision’ was not declared in this scope
673 | << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << LedMean[ch] << "\t" << LedSD[ch] << "\t" << LedMean[ch]/LedMean[refencechannel] << "\n";
| ^~~~~~~~~~~~
display_calibration/Read_calibration.cxx:690:28: error: ‘setw’ was not declared in this scope; did you mean ‘getw’?
690 | outputfileLED << setw(4) << left << chlist+1 << "\t" << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << LedMean[ch] << "\t" << LedSD[ch] << "\t" << LedMean[ch]/LedMean[refencechannel] << "\n";
| ^~~~
| getw
display_calibration/Read_calibration.cxx:690:124: error: ‘setprecision’ was not declared in this scope
690 | << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << LedMean[ch] << "\t" << LedSD[ch] << "\t" << LedMean[ch]/LedMean[refencechannel] << "\n";
| ^~~~~~~~~~~~
display_calibration/Read_calibration.cxx:703:33: error: ‘setw’ was not declared in this scope; did you mean ‘getw’?
703 | if(lflag==1) outputfileLED << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << LedMean[ch] << "\t" << LedSD[ch] << "\t" << LedMean[ch]/LedMean[refencechannel] << "\n";
| ^~~~
| getw
display_calibration/Read_calibration.cxx:703:89: error: ‘setprecision’ was not declared in this scope
703 | D << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << LedMean[ch] << "\t" << LedSD[ch] << "\t" << LedMean[ch]/LedMean[refencechannel] << "\n";
| ^~~~~~~~~~~~
display_calibration/Read_calibration.cxx:704:39: error: ‘setw’ was not declared in this scope; did you mean ‘getw’?
704 | if(sflag==1) outputfileSKY << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << SkyMean[ch] << "\t" << SkySD[ch] << "\n";
| ^~~~
| getw
display_calibration/Read_calibration.cxx:704:95: error: ‘setprecision’ was not declared in this scope
704 | Y << setw(4) << left << ch+1 << "\t" << setw(5) << fixed << setprecision(1) << setw(5) << SkyMean[ch] << "\t" << SkySD[ch] << "\n";
| ^~~~~~~~~~~~
make: *** [Makefile:147: display_calibration/Read_calibration] Error 1