I'm fiddling around with GCC, trying to understand the various possibilities for linkage.
These are my questions:
Let's say I have two files
tools.c
andtools.h
, and I create an archivelibtools.a
(containingtools.o
).Now I have some
prog.c
, a program which includestools.h
and uses some of its functions.are the following commands equivalent?
gcc -Wall prog.c libtools.a -o prog
gcc -Wall prog.c -ltools -o prog
regarding the
-l
flag (man ld
wasn't of much use unfortunately):a. What is the implicit pattern matching rule? -lX means "find the file named libX.a"?
b. Does
-l
have any real importance in the linking process besides finding the library lazily (closely related to 1 I guess)?c. How do I link a library named
lib.a
ortools.paz
?