Compile Error for Arduino Mega
tldr; -lc means "link with the libc.a library"

The compiler takes your source code (*.c, *.ino) and produces "object" files ending in *.o.

The linker takes those compiled modules and links them all together to make the final executable, linking symbols in one file (such as variable references and function calls) with the definitions in the others (the actual variables and functions). But it also takes libraries - predefined collections of object files - and links those in as well, if necessary.

Libraries are files of the form lib*.a (a is for "archive"), and are distributed by software vendors as easy containers for their modules. The compiler/linker itself also uses them as the implementations for languages features such as printf() and digitalWrite(). The most fundamental library is libc.a - the library containing the standard C implementation.

When you want to get the linker to use a library, you give it the -l option, with the library name appended (not including the lib prefix and .a extension). In short, -lc means "link with the libc.a library".

But if your development machine has support for numerous processors, there will be a number of libc.a files on it - how does the linker know where to look? Another linker option is -L (note uppercase), which defines the directories to look in to find libraries. The linker will look through the directories in turn until it finds the referenced library.

If you attempt to link modules that have been compiled for different processors, you will get linker errors when it does a sanity check. The reason your fix worked is because it now uses the correct directories to find what it is looking for.