Reputation: 1494
Guys gave me their library: libA.a
and libB.a
. Also, I have header files: header_A.h
and header_B.h
. I need to add them to my Makefile
. I've added this:
INCLUDES = -I/home/me/lib_from_guys/include
LIBS = -L/home/me/lib_from_guys/libraries
CFLAGS = -llibA -llibB
hello:
$(CC) $(INCLUDES) $(LIBS) $(CFLAGS) $< -o $@
BUT! compiler said, that it could not find libA
and libB
. I've changed on this:
CFLAGS = -lA -lB
And now it works. Is it necessary always supress "lib"
prefix in lib? Or how it knows names of my libraries?
Upvotes: 0
Views: 99
Reputation: 16331
This has been a standard behavior in C for many, many years.
The -lX
option will automatically prompt the linker to look for something named libX
, not X
. So, yes, you always exclude the lib
portion of the name to -l
.
Upvotes: 3