Q:

C identifying the library name for -l flag?

When including a library for gcc (-l or lower case -L) how would I know the library name to put inside that parameter for a specific header file?
an example (but I am looking for a more general answer):
my c file (named doSomething.c) might have:
#include <libv4l2.h>
...
...

my gcc statement would look like:
gcc -o doSomething doSomething.c -lv4l2

In this case I knew I needed to include the library v4l2, if I hadn't known is there a generic way of finding that name?
any help would be appreciated
thanks

A:

Whoever supplied you with the library should tell you its name. Often, that is vague, implied, buried in documentation, or left to convention.
To start with, you can pass any library to the linker by using the full path in the file system, such as /usr/lib/libfoo.so or ~myaccount/mystuff/bar.a.
The linker has a built-in list of standard places to look for libraries, so you can leave off the directory part of the path and just name the file, like libfoo.so. You can also add directories to this list with the -L switch (for common linkers on POSIX and other systems).
If the file name has the form libfoo.a or other extensions recognized by the linker, you can abbreviate it with -lfoo.
So, if the library is installed in a standard place with a standard name, you can link it with -lfoo, and the vendor or other supplier should tell you what foo is.
If the library is part of a software package that is installed on your system but is not a standard part of the system, you can ask your system administrator what the name is, and, if it is not in a standard location, where they installed it.

