Please read tips for efficient and successful posting and posting code
Please fill also the fields below. Note that root -b -q
will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug
from the ROOT prompt to pre-populate a topic.
ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided
Hello everyone.
I’ve just installed ROOT in my new laptop and I am having trouble trying to run my first problem. I imported this Makefile from my previous laptop because it was working well:
SRC = $(wildcard src/*.cpp)
INC = $(wildcard src/*.h)
MAIN = $(wildcard main/*.cpp)
CXX = g++ $(shell root-config --cflags) -I src
ROOTLIB = $(shell root-config --libs)
####################################
SRC_OBJ = $(patsubst %.cpp, bin/%.o, $(notdir $(SRC)))
MAIN_OBJ = $(patsubst %.cpp, bin/%.o, $(notdir $(MAIN)))
bin/%.exe: bin/%.o $(SRC_OBJ)
@echo "compiling and liking file [ $< ] to $@ "
$(CXX) $< -o $@ $(SRC_OBJ) $(ROOTLIB)
bin/%.o: src/%.cpp
@echo "compiling file [ $< ] to $@ "
$(CXX) -c $< -o $@
bin/%.o: main/%.cpp
@echo "compiling file [ $< ] to $@ "
$(CXX) -c $< -o $@
####################################
FTILDE = $(wildcard src/~) $(wildcard main/~)
FBIN = $(wildcard bin/*.o)
clean:
@echo "cleaning..."
@rm -fv $(FBIN)
dump:
@echo "dump list of src files..."
@echo $(SRC)
@echo $(INC)
@echo $(MAIN)
@echo $(FTILDE)
@echo $(FBIN)
@echo $(CXX)
@echo $(SRC_OBJ)
However, while compiling a file containg TApplication, TGraph, etc, this error occured:
make: root-config: No such file or directory
compiling file [ main/fitPanel.cpp ] to bin/fitPanel.o
g++ -I src -c main/fitPanel.cpp -o bin/fitPanel.o
main/fitPanel.cpp:8:10: fatal error: TApplication.h: No such file or directory
8 | #include "TApplication.h"
| ^~~~~~~~~~~~~~~~
compilation terminated.
make: *** [Makefile:29: bin/fitPanel.o] Error 1
and I don’t understand why, since it was working in my previous laptop, with the same file…
I believe the error is due to the fact that it is not finding root-config, because the path for the ROOT Libraries are ok.
I would appreciate your help.
Here is the file that I am trying to compile, if needed:
/*
Fitar dados a gaussianas. O programa abre o fitPanel para ser mais rápido e prático. Incertezas no eixos dos yy
*/
#include <iostream>
#include <fstream>
#include <vector>
#include <sstream>
#include "TApplication.h"
#include "TF1.h"
#include "TCanvas.h"
#include "TGraphErrors.h"
#include "TAxis.h"
void FitData()
{
// Create a TApplication for the ROOT graphics
TApplication app("app", nullptr, nullptr);
// Read data from file
std::ifstream file("/home/diogo/analysis/main/data/something.txt");
if (!file.is_open())
{
std::cout << "Failed to open data file." << std::endl;
return;
}
// Arrays to store data
std::vector<double> xValues;
std::vector<double> NA_Values;
std::vector<double> v_NA_Errors;
std::vector<double> NB_Values;
std::vector<double> v_NB_Errors;
std::vector<double> NC_Values;
std::vector<double> v_NC_Errors;
std::string line;
while (std::getline(file, line))
{
std::istringstream iss(line);
double x, NA, NA_err, NB, NB_err, NC, NC_err;
if (iss >> x >> NA >> NA_err >> NB >> NB_err >> NC >> NC_err)
{
xValues.push_back(x);
NA_Values.push_back(NA);
v_NA_Errors.push_back(NA_err);
NB_Values.push_back(NB);
v_NB_Errors.push_back(NB_err);
NC_Values.push_back(NC);
v_NC_Errors.push_back(NC_err);
}
}
file.close();
// Create a TGraphErrors from the data
int numPoints = xValues.size();
TGraphErrors *graph = new TGraphErrors(numPoints, &xValues[0], &NC_Values[0], 0, &v_NC_Errors[0]);
graph->SetTitle("Blindagem");
graph->GetXaxis()->SetTitle("#theta (degrees)");
graph->GetYaxis()->SetTitle("NC(#theta) (cts)");
graph->GetXaxis()->CenterTitle(true);
graph->GetYaxis()->CenterTitle(true);
// Create a canvas to display the graph
TCanvas *canvas = new TCanvas("canvas", "Data Fitting", 800, 600);
graph->Draw("AP"); // "AP" option to display both markers and error bars
// Launch the ROOT Fit Panel
canvas->Update(); // Update the canvas to display the graph
canvas->cd();
graph->FitPanel();
// Wait for the Fit Panel to be closed
app.Run();
}
int main()
{
FitData();
return 0;
}
Thank you,
Diogo Franco