Compiling macros problem

Hi,

following the compiling how-to I copied Makefile.arch from my root/test folder and then I did the following Makefile (which I don’t fully understand…):

include Makefile.arch

read_bin2O      = read_bin2.$(ObjSuf)
read_bin2S      = read_bin2.$(SrcSuf)
read_bin2       = read_bin2$(ExeSuf)

$(read_bin2):   $(read_bin2O)
		$(LD) $(LDFLAGS) $^ $(LIBS) $(OutPutOpt) $@
		@echo "$@ done"

.SUFFIXES: .$(SrcSuf)

.$(SrcSuf).$(ObjSuf):
	$(CXX) $(CXXFLAGS) -c $<

OBJ_FILES = $(read_bin2O)
EXE_FILES = $(read_bin2)

.PHONY : clean
clean:
	rm $(OBJ_FILES) $(EXE_FILES)

but I get this error:

fede@PMTanalisis:~/usr2/fuentes$ make read_bin2
cc    -c -o read_bin2.o read_bin2.c
read_bin2.c:4:19: error: TROOT.h: No such file or directory
read_bin2.c:5:21: error: TNtuple.h: No such file or directory
read_bin2.c:6:20: error: TStyle.h: No such file or directory
read_bin2.c:7:19: error: TFile.h: No such file or directory
read_bin2.c: In function ‘ntuple_gen’:
read_bin2.c:28: error: ‘TFile’ undeclared (first use in this function)
read_bin2.c:28: error: (Each undeclared identifier is reported only once
read_bin2.c:28: error: for each function it appears in.)
read_bin2.c:28: error: ‘file’ undeclared (first use in this function)
read_bin2.c:28: error: expected ‘;’ before ‘:’ token
read_bin2.c:29: error: ‘TNtuple’ undeclared (first use in this function)
read_bin2.c:29: error: ‘nt’ undeclared (first use in this function)
read_bin2.c:29: error: ‘new’ undeclared (first use in this function)
read_bin2.c:29: error: expected ‘;’ before ‘TNtuple’
make: *** [read_bin2.o] Error 1

doing root-config --arch gives me linux. (I’m running ubuntu server 8.04)

Looking in other threads I found that doing the following works perfectly:

g++ `root-config --cflags --glibs` read_bin2.c -o read_bin2

so, I wonder what I’m doing wrong in my Makefile…

Ok, hope you can help me. Thanks.

fede.

Where do you define CXXFLAGS ?
see example in $ROOTSYS/test/Makefile, Makefile.arch

Rene

[quote=“brun”]Where do you define CXXFLAGS ?
see example in $ROOTSYS/test/Makefile, Makefile.arch

Rene[/quote]

well, CXXFLAGS is set in the Makefile.arch located in the same folder where my program is, I copied it from /usr/share/doc/root/test/Makefile.arch

I already was taking a look at the Makefile.arch and looks exactly as any other Makefile.arch… as far as I can tell, it should work…

something strange is that I don’t have the $ROOTSYS variable set… and I really don’t know exactly how to do it since I installed root from debian repositories

and I can’t find any classical root folder… I mean, I have:
/usr/bin/root
/usr/bin/root-config
and as far as I can see, libraries are here:
/usr/lib/root/

I’m a little confused…

fede.

Hi,

the problem is that SrcSuf is “cxx”, but you have a C file, so that rule is never used and make’s generic, built-in rule for compiling C files is used instead. Either extend your Makefile to also support C files, or - if it doesn’t have to stay in C - rename your .c file to .cxx.

Cheers, Axel.

Ok, I’m an idiot…

I already tried creating a file .cxx because I saw that on the makefile.arch but it didn’t work because I left the old .c file in the same folder.

I mean, you are right… the file has to be named .cxx.

Thanks a lot!!!

fede.