arduino-mk gives error for EEPROM library

I think it's definitely using a different library. Your compilation command contains this:

-I/usr/share/arduino/libraries/EEPROM

but the Arduino IDE is likely using the EEPROM library at a different location. It really doesn't make sense to have the EEPROM library installed at /usr/share/arduino/libraries/EEPROM because that's a hardware-specific library and thus each hardware platform provides its own version of the EEPROM library so it should be located in the libraries subfolder of the hardware package.

You can find the location of the EEPROM library used by the Arduino IDE by doing this:

  • Tools > Board > Arduino/Genuino Mega
  • File > Examples > EEPROM > eeprom_clear
  • Sketch > Show Sketch Folder
  • Navigate up two folder levels. The source files for the library will there or under the src subfolder.