Compiling Error

Hi all,

I am not very good at programming yet and I have a hard time understanding what some of the errors mean. I am trying to compile some code but when I do 'make' I get the following error.

1
2
3
4
5
6
7
Compiling BeamHist.o
g++: error: missing path after ‘-I’
GNUmakefile:16: recipe for target 'BeamHist.o' failed
make[1]: *** [BeamHist.o] Error 1
make[1]: Leaving directory '/home/christianwos/Desktop/numi_flux_zarko/flux/src'
GNUmakefile:4: recipe for target 'all' failed
make: [all] Error 2 (ignored)


I am not sure about what this means. The makefile is the one posted below. Can anybody explain to me? I did not write this code, I just inherited from someone else.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
TARGET = BeamHist

OBJS_CXX = $(TARGET).o data_t.o GnumiHistMaker.o NuWeight.o
SRCS = $(TARGET).C data_t.cxx GnumiHistMaker.cxx NuWeight.cxx

ROOTLIBS = $(shell $(ROOTSYS)/bin/root-config --libs) -lMinuit
EXTRALIBS = -lm -lboost_program_options -L$(BOOST_LIB)

CPPFLAGS   +=  -O3 -m64 -std=c++11
CPPFLAGS   +=  -I$(ROOTSYS)/include -I$(BOOST_INC) 

CC = @echo Compiling $@; g++
LD = @echo Linking $@; ld

%.o: %.C
	$(CC) -c $*.C  $(CPPFLAGS)

#@echo Here...

%.o: %.cxx
	$(CC) -c $*.cxx $(CPPFLAGS)

$(TARGET) : $(OBJS_CXX)
	$(CC) $(OBJS_CXX) $(ROOTLIBS) $(EXTRALIBS) -o $(TARGET)
#	$(CC) -o $(TARGET) $(OBJS_CXX) $(ROOTLIBS) $(EXTRALIBS)
	@cd ../bin; ln -s -f ../src/$(TARGET)

data_t.o: data_t.cxx data_t.h

GnumiHistMaker.o: GnumiHistMaker.cxx GnumiHistMaker.h NuWeight.h data_t.h

NuWeight.o: NuWeight.cxx NuWeight.h

BeamHist.o: data_t.h GnumiHistMaker.h NuWeight.h GnumiHistMaker.h


.PHONY : clean
Last edited on
g++: error: missing path after ‘-I’
GNUmakefile:16: recipe for target 'BeamHist.o' failed

Ok, its line 16:
	$(CC) -c $*.cxx $(CPPFLAGS)

Lets put the values of CC, * and CPPFLAGS into that:
@echo Compiling $@; g++  -c BeamHist.C -I$(ROOTSYS)/include -I$(BOOST_INC)

Lets put the values of @, ROOTSYS and BOOST_INC into that:
@echo Compiling BeamHist.o
g++  -c BeamHist.C -I/include -I

There you have it: a lone -I without a pathname after it.

The real issue is that neither the ROOTSYS nor the BOOST_INC environment values have been set any value. Your "uncle" must have had them defined before calling make.
Last edited on
show the build command
1
2
CC =  g++
LD = ld



I'll guess that you have undefined variables CPPFLAGS += -I$(ROOTSYS)/include -I$(BOOST_INC)
Thank you to both of you. I define the ROOTSYS variables by sourcing . bin/thisroot.sh at startup. However, I did not define the BOOST_INC and BOOST_LIB variables.

But I don't know how to find them on my system. The other person had them at

1
2
export BOOST_INC=/usr/include/boost
export BOOST_LIB=/usr/lib 


While I also have the above directories on my machine,they must clearly give the wrong path. But I am not sure how to find them. I have tried both

grep -r VARIABLE NAME /etc/*
grep -r VARIABLE NAME ~/.*

to no avail. Is there another way?
You should have the boost installed by some means. Hopefully via a package manager. Such manager should have tools to list installed packages and list files of a package.
We can obviously not help about details that you have not told about.

Some of the boost packages must have linkable libraries (*.so or *.a). It is quite likely that they are in /usr/lib or /usr/lib64, but could be elsewhere.

The boost header files could be in /usr/include, but more likely within subdirectory. If I were you, I would look from the source code what headers are included.

It is quite likely that the boost includes contain relative path. For example:
1
2
3
#include <boost/algorithm/cxx11/all_of.hpp>
// rather than
#include <all_of.hpp> 

Lets assume that 'all_of.hpp' is installed, under /usr, and we have not found it by other means:
find /usr -type f -name all_of.hpp -ls

should then list the file.

If the output says that file is:
/usr/include/boost/algorithm/cxx11/all_of.hpp

That would require BOOST_INC=/usr/include
I do have boost installed under /home/christianwos/.

The BeamHist.C has an

 
#include <boost/program_options.hpp> 


I found it to be under

 
/usr/include/boost/program_options.hpp


So the path BOOST_INC=/usr/include should be teh correct one. But for some reason it isn't. What about the BOOST_LIB?
1
2
3
4
5
export BOOST_INC=/usr/include/boost
export BOOST_LIB=/usr/lib


#include <boost/program_options.hpp> 
ah, standard path, no need for -I or -L flags


> I do have boost installed under /home/christianwos/.
> I found it to be under /usr/include/boost/program_options.hpp
decide yourself


> But for some reason it isn't
If you've got any error, then post the error verbatim.
Are you saying that I need to remove the

1
2
-L$(BOOST_LIB)
-I$(BOOST_INC)

from lines 7 and 10, respectively?

What I meant is that I have the boost package extracted under
/home/christianwos/boost_1_64_0

but if I do 'locate' program_options.hpp I get two outputs:

1
2
/home/christianwos/Desktop/boost_1_64_0/boost/program_options.hpp
/usr/include/boost/program_options.hpp

So, which one is it?

The error is what I posted in my first post.

1
2
3
4
5
6
7
Compiling BeamHist.o
g++: error: missing path after ‘-I’
GNUmakefile:16: recipe for target 'BeamHist.o' failed
make[1]: *** [BeamHist.o] Error 1
make[1]: Leaving directory '/home/christianwos/Desktop/numi_flux_zarko/flux/src'
GNUmakefile:4: recipe for target 'all' failed
make: [all] Error 2 (ignored)


Thank you.
Last edited on
sure, remove them.
It seems that the library was installed already, and it's in a sane path.
use that one.


> g++: error: missing path after ‘-I’
show your build command. (I'm not talking about make, but the commands that make execute)
Last edited on
Thank you so much for your help (both of you). Removing the flags helped and I was able to compile the code.
Topic archived. No new replies allowed.