When I compile code using GNU Make I get multiple warnings like:
clang: warning: -lGui: 'linker' input unused
This is probably because I have messed something up in my Makefile (below). Can anyone point me toward the problem?
CXX=g++
CC=g++
CXXFLAGS=-g -Wall -W -Wshadow -Wcast-qual -Wwrite-strings $(shell root-config --cflags --glibs)
CPPFLAGS+=-MMD -MP
LDFLAGS=-g $(shell root-config --ldflags)
LDLIBS=$(shell root-config --libs)
xSec_x: xSec_x.o xSec.o Analysis.o
-include xSec_x.d xSec.d Analysis.d
xSec.o: xSec.cpp xSec.h Analysis.h Analysis.cpp
xSec_x.o: xSec_x.cpp xSec.h Analysis.h
clean:
rm -f @rm -f $(PROGRAMS) *.o *.d
That message means you are passing linker flags (like -l
which tells the linker to pull in a library) to the compiler.
This means that the result of running root-config --cflags --glibs
is generating linker flags, and those are going into CXXFLAGS
, which is being passed to the compiler. I don't know what root-config
is, but you should investigate its command line and invoke it in a way where it doesn't generate linker flags. Probably removing the --glibs
option will do it.
ETA: you really want to be using :=
to assign these flags variables if you're going to run $(shell ...)
there. It will work either way, but if you use =
then the shell command will be run every time make expands the variable, which is once per compilation. If you use :=
it will only be run once, when the makefile is parsed.
I got this same error and the reason was that I forgot to add -I
in front of my included paths for cflags in makefile. For example:
CFLAGS += $(path)/dir/subdir/include -> Got the above mentioned error.
CFLAGS += -I$(path)/dir/subdir/include -> Fixed the issue.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With