gcc -l without source files invokes linker

Jeff Epler jepler@unpythonic.net
Sun Oct 26 02:19:00 GMT 2014


It's possible, though probably atypical, to list only libraries on a
linker commandline.

For example this sequence creates a program, despite the fact that it
listed only libraries on the commandline:
    $ echo 'int main(){return 0;}' > main.c
    $ gcc -c main.c
    $ ar cur libmain.a main.o
    $ gcc -L. -lmain
    $ ./a.out

Jeff



More information about the Gcc-help mailing list