Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

clang: warning: -l*: 'linker' input unused

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
like image 414
mareks Avatar asked Nov 04 '13 18:11

mareks


2 Answers

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.

like image 191
MadScientist Avatar answered Sep 23 '22 08:09

MadScientist


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.
like image 44
ManyuBishnoi Avatar answered Sep 22 '22 08:09

ManyuBishnoi