24

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

2 Answers 2

18

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.

Sign up to request clarification or add additional context in comments.

1 Comment

D'oh! I was passing all the linker flags to the compiler... I wish clang was a little more descriptive. The error makes it sound like the lib was ignored because the code never used its symbols.
8

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.