Compile via makefile

Hi,

I try to compile my program via a makefile for a few hours now. It’s working very well till I add Root to my program. Can you please have a look ?

My makefile:

[code]CXX = g++
CXXFLAGS = -g -Wall root-config --libs --cflags -fPIC -O3

LD = g++
LDFLAGS = -g

SOURCES=$(wildcard *.cpp)
OBJECTS=$(SOURCES:.cpp=.o)
HEADERS=$(SOURCES:.cpp=.h)
EXECUTABLE=matching

CXXFLAGS += $(shell root-config --cflags)
LIBS = $(shell root-config --libs)
NGLIBS = $(shell root-config --glibs)
GLIBS = $(filter-out -lNew, $(NGLIBS))

.SUFFIXES: .cpp

================================================================================

all: $(SOURCES) $(EXECUTABLE)

$(EXECUTABLE): $(OBJECTS)
$(CXX) $(CXXFLAGS) $(OBJECTS) -o $@ $(LIBS)

.cpp.o: $(SOURCES) $(HEADERS)
$(CXX) -c $(CXXFLAGS) $< -o $@ -I$(PWD)

clean:
rm -f $(EXECUTABLE) *.o [/code]

in my matching.cpp I’m currently trying to run it with only “TCanvas* c=new TCanvas(“APD_fit”,“APD fit”,1400,1000);” in my main(). The following is the compilation result:

matching.cpp:100:3: error: ‘TCanvas’ was not declared in this scope TCanvas* c=new TCanvas("APD_fit","APD fit",1400,1000); ^ matching.cpp:100:12: error: ‘c’ was not declared in this scope TCanvas* c=new TCanvas("APD_fit","APD fit",1400,1000); ^ matching.cpp:100:18: error: expected type-specifier before ‘TCanvas’ TCanvas* c=new TCanvas("APD_fit","APD fit",1400,1000);

The used directives are
#include
#include
#include
#include
#include
#include
#include <stdio.h>
#include <stdlib.h>
#include <TF1.h>
#include <TH1.h>
#include <TH1F.h>
#include <TH1D.h>
#include <TFile.h>

Anybody a clue ? Thank you very much in advance!

Hi,

#include “TCanvas.h” is missing.

Axel

:laughing: :laughing: :laughing: :laughing: :laughing: :laughing: :laughing: :laughing: :laughing: :laughing: :laughing:

that’s not true… yeah, it is, it’s working now…
can’t believe how I wasted the last hours…

Thank you very much…!