Pages

Wednesday, 5 August 2020

Note: The -L and -l options must be AFTER the file to be compiled by gcc




gcc -o hello.elf hello.o -L. -lmylib
gcc -o hello.elf -L. -lmylib hello.o
 


Be careful about the order of the parameters when using gcc; the -l option is a linker option, and thus needs to be placed AFTER the name of the file to be compiled. This is quite different from the normal option syntax. If you place the -l option before the filename, it may fail to link at all, and you can end up with mysterious errors.

No comments:

Post a Comment