23

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
mareks
  • 481
  • 2
  • 5
  • 13

2 Answers2

17

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.

MadScientist
  • 92,819
  • 9
  • 109
  • 136
  • 2
    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. – Navin Jun 15 '15 at 17:16
7

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.
wogsland
  • 9,106
  • 19
  • 57
  • 93
ManyuBishnoi
  • 339
  • 5
  • 9