Compilation failed after installing root with brew

Dear all,

I recently installed a new root version (6.30/04) using ‘brew install ROOT.’
But now my code is not compiling anymore.
I am getting the attached error when I compile with make:

Do you know what could be the issue?

In case it’s useful, my Mac version is: macOS Sonoma version 14.3.1. and my Xcode version is 15.2.
I was trying to build root from source, but I was getting some errors, that’s why I use brew.
Note also if, I use a simple script (let’s say script.C) that I can run with something like root -l script.C, it run without any errors.
I attached my code.
Processing: preparingInputForLimit.cpp…Processing: functionForMain.h…
declarationFile.h (10.7 KB)
Let me know if you want to look at the Makefile I am using.



I thought I fixed, but it doesn’t seem to be the case. Here is my Makefile.

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

EXECUTABLE = preparingInputForLimit
INCLUDES = -I$(ROOTSYS)/include  -I/usr/local/Cellar/eigen/3.3.7/include/eigen3/

# You can modify the below as well, but probably
# wont 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.


LDFLAGS = -L$(ROOTSYS)/lib `root-config --glibs` -lSpectrum -lRooFit -lRooFitCore -lMinuit 

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

CXX = g++ -g -std=c++14 

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.


# 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.


# 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.

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

	@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)


Changing this line CFLAGS = -Wall to this CFLAGS = -c -g -Wall root-config --cflags in my Makefile, solved the issue.


Dear @diboye ,

I am glad you could find a solution, in fact passing ${root-config --cflags} to your compiler invocation is necessary in any case, I am not sure if in the past you didn’t do this, it would be highly suspicious if that worked, probably something else in your environment was doing it for you if that was the case.


This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.