[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: using -l in gcc

On Mon, 13 Oct 1997, Shaleh wrote:

> How do I make a library available to gcc -l i.e. gcc -lX11 or gcc
> -lmy_own_lib?  Same question applies to -i as well I suppose.

If you only want it to happen for one command you can use the -I (that's a
capital "i") and -L switches; for example, if your libraries are in
/home/shaleh/lib and you headers in /home/shaleh/include:
gcc -L/home/shaleh/lib/ -I/home/shaleh/lib -lmy_own_lib -o foo foo.c
(note that the second option is a capital "i"; the third option is a
lowercase "L")

But what if you want to use this on more than just one command?  The
easiest way to do so is with environment variables; from the gcc info

     The value of `LIBRARY_PATH' is a colon-separated list of
     directories, much like `PATH'.  GNU CC tries the directories thus
     specified when searching for special linker files, if it can't
     find them using `GCC_EXEC_PREFIX'.  Linking using GNU CC also uses
     these directories when searching for ordinary libraries for the
     `-l' option (but directories specified with `-L' come first).

     These environment variables pertain to particular languages.  Each
     variable's value is a colon-separated list of directories, much
     like `PATH'.  When GNU CC searches for header files, it tries the
     directories listed in the variable for the language you are using,
     after the directories specified with `-I' but before the standard
     header file directories.

TO UNSUBSCRIBE FROM THIS MAILING LIST: e-mail the word "unsubscribe" to
debian-user-request@lists.debian.org . 
Trouble?  e-mail to templin@bucknell.edu .

Reply to: