Make sure that the -L
option appears ahead of the -l
option; the order of options in linker command lines does matter, especially with static libraries. The -L
option specifies a directory to be searched for libraries (static or shared). The -lname
option specifies a library which is with libmine.a
(static) or libmine.so
(shared on most variants of Unix, but Mac OS X uses .dylib
and HP-UX used to use .sl
). Conventionally, a static library will be in a file libmine.a
. This is convention, not mandatory, but if the name is not in the libmine.a
format, you cannot use the -lmine
notation to find it; you must list it explicitly on the compiler (linker) command line.
The -L./libmine
option says "there is a sub-directory called libmine
which can be searched to find libraries". I can see three possibilities:
libmine.a
, in which case you also need to add -lmine
to the linker line (after the object files that reference the library).libmine
that is a static archive, in which case you simply list it as a file ./libmine
with no -L
in front. libmine.a
in the current directory that you want to pick up. You can either write ./libmine.a
or -L . -lmine
and both should find the library.