Makefile trouble

Hi Everyone,
I wanna use a compiled code, but I don’t know why if do [quote] make[/quote] it doesn’t compile, but got this errors:

g++ -g -std=c++11 -Wall -I/include   -c -o Analyse.o Analyse.C
cc1plus: erreur: option "-std=c++11" de la ligne de commande non reconnue
make: *** [Analyse.o] Erreur 1

the Makefile is :

# Lines starting with the pound sign are comments.
#
# These are the two options that may need tweaking

EXECUTABLE = Analyse
LINKCC = $(CXX)
INCLUDES = -I$(ROOTSYS)/include

# You can modify the below as well, but probably
# won't need to
#

# CC is for the name of the C compiler. CPPFLAGS denotes pre-processor
# flags, such as -I options. CFLAGS denotes flags for the C compiler.
# CXXFLAGS denotes flags for the C++ compiler. You may add additional
# settings here, such as PFLAGS, if you are using other languages such
# as Pascal.

CPPFLAGS =

LDFLAGS = -L$(ROOTSYS)/lib `root-config --glibs`
#SOURCES=main_llllTree.cpp llllTree2.C

 CC = gcc -g -std=c++11
CC = gcc -g
#CFLAGS = -Wall -O2
CFLAGS = -Wall

CXX = g++ -g -std=c++11
CXXFLAGS = $(CFLAGS) $(INCLUDES)

SRCS := $(wildcard *.c) $(wildcard *.cpp) $(wildcard *.C)
OBJS := $(patsubst %.c,%.o,$(wildcard *.c)) \
	$(patsubst %.cpp,%.o,$(wildcard *.cpp)) \
	$(patsubst %.C,%.o,$(wildcard *.C))
DEPS := $(patsubst %.o,%.d,$(OBJS))

# "all" is the default target. Simply make it point to myprogram.

all: $(EXECUTABLE)

# Define the components of the program, and how to link them together.
# These components are defined as dependencies; that is, they must be
# made up-to-date before the code is linked.

$(EXECUTABLE): $(DEPS) $(OBJS)
	$(LINKCC) $(LDFLAGS) -o $(EXECUTABLE) $(OBJS)

# Specify that the dependency files depend on the C source files.

%.d: %.c
	$(CC) -MM $(CPPFLAGS) $< > $@
	$(CC) -MM $(CPPFLAGS) $< | sed s/\\.o/.d/ >> $@

%.d: %.cpp
	$(CXX) -MM $(CXXFLAGS) $(CPPFLAGS) $< > $@
	$(CXX) -MM $(CXXFLAGS) $(CPPFLAGS) $< | sed s/\\.o/.d/ >> $@

%.d: %.C
	$(CXX) -MM $(CXXFLAGS) $(CPPFLAGS) $< > $@
	$(CXX) -MM $(CXXFLAGS) $(CPPFLAGS) $< | sed s/\\.o/.d/ >> $@

# Specify that all .o files depend on .c files, and indicate how
# the .c files are converted (compiled) to the .o files.

clean:
	-rm $(OBJS) $(EXECUTABLE) $(DEPS) *~

explain:
	@echo "The following information represents your program:"
	@echo "Final executable name: $(EXECUTABLE)"
	@echo "Source files:     $(SRCS)"
	@echo "Object files:     $(OBJS)"
	@echo "Dependency files:   $(DEPS)"

depend: $(DEPS)
	@echo "Dependencies are now up-to-date."

-include $(DEPS)

I attached the others files which are in the same folder than Makefile.
I would really appreciate if someone could help please.
Cheers
llllTree2.h (190 KB)
llllTree2.C (2.1 KB)
Analyse.C (5.05 KB)

What do you get from:
g++ --version
root-config --cxx --cflags

Hi Pepe,
Thanks for replying, so from g++ --version, I get:

g++ (GCC) 4.4.7 20120313 (Red Hat 4.4.7-17)
Copyright © 2010 Free Software Foundation, Inc.
Ce logiciel est libre; voir les sources pour les conditions de copie.  Il n'y a PAS
GARANTIE; ni implicite pour le MARCHANDAGE ou pour un BUT PARTICULIER.

and from root-config --cxx --cflags, I get:

g++ -pthread -m64 -I/usr/include/root

Sorry for the french output of my terminal, I don’t know why it does that
Cheers

gcc 4.4.7 does not support c++11.
I guess you would need at least gcc 4.8.x for c++11.

And be warned … if your “new” gcc/g++/gfortran come from one of the:
“old” RedHat “Developer Toolset”: linux.web.cern.ch/linux/devtoolset/
“new” RedHat “Software Collections”: linux.web.cern.ch/linux/scl/
then you will not be able to build ROOT 6, but you should be able to build and use ROOT 5 without problems (and compile your own code with “-std=c++11”, even when using ACLiC).

Hi Pepe,
I am in lxplus and my root version is 5.34/36, so it should be fine to use the “old” RedHat or the “new” one according to your last message. but the problem is I am not allowed to install none of them following the link you sent me, for instance if I do:

yum install devtoolset-2

I have:

Loaded plugins: kernel-module, priorities, refresh-packagekit, rpm-warm-cache,
              : security, versionlock
You need to be root to perform this command.

On SLC6 LXPLUS, you should be able to use AFS … in your shell, execute: . /afs/cern.ch/sw/lcg/external/gcc/4.9/x86_64-slc6-gcc49-opt/setup.sh

Hi Pepe
Thanks this updated my gcc version and I don’t have this error anymore. But I have this now:

g++ -g -std=c++11 -Wall -I/include   -c -o Analyse.o Analyse.C
Analyse.C:5:20: fatal error: TStyle.h: No such file or directory
 #include <TStyle.h>
                    ^
compilation terminated.
make: *** [Analyse.o] Error 1

it doesn’t understand all the root includes, (not only this TStyle, even TCanva …) which are defined in Makefile by

LDFLAGS = -L$(ROOTSYS)/lib `root-config --glibs`

cheers

CXX="root-config --cxx
CPPFLAGS=”root-config --cflags -std=c++11"
CXXFLAGS="${CPPFLAGS}“
LINKCC=”${CXX}“
LDFLAGS=”${CXXFLAGS}“
LDLIBS=”root-config --glibs"

$(LINKCC) $(LDFLAGS) -o $(EXECUTABLE) $(OBJS) $(LDLIBS)

Hi,
Thanks so much Pepe