gcc -l länkar med en biblioteksfil.
gcc -L letar i katalogen efter biblioteksfiler.
$ gcc [options] [source files] [object files] [-Ldir] -llibname [-o outfile]
Länk -l med biblioteksnamn utan lib-prefixet och tilläggen .a eller .so .
För statisk biblioteksfil libmath. en användning- lmath :
$ gcc -static myfile.c -lmath -o myfile
För delat biblioteksfil libmath. så använd -lmath :
$ gcc myfile.c -lmath -o myfile
file1.c:
// file1.c
		#include <stdio.h/
		void main()
		{
		    printf("main() run!\n");
		    myfunc();
		}
file2.c:
// file2.c
		#include <stdio.h/
		void myfunc()
		{
		    printf("myfunc() run!\n");
		}
Bygg file2.c , kopiera objektfil file2.o till libs- katalogen och arkivera den till det statiska biblioteket libmylib.a :
$ gcc -c file2.c
		$ mkdir libs
		$ cp file2.o libs
		$ cd libs
		$ ar rcs libmylib.a file2.o
Bygg file1.c med det statiska biblioteket libmylib.a i libs- katalogen.
Bygg utan -L-resultat med ett fel:
$ gcc file1.c -lmylib -o outfile
		/usr/bin/ld: cannot find -llibs
		collect2: ld returned 1 exit status
		$
Bygg med -L och kör:
$ gcc file1.c -Llibs -lmylib -o outfile
		$ ./outfile
		main() run!
		myfunc() run!
		$