The reference to line 14 is in main.cpp.
The code for this is in ../hardware/arduino/cores/arduino
it is short therefore I reproduce it here.:
if (serialEventRun) serialEventRun();
I note that it contains the include directive
which contains the definition of loop i.e
So I must assume that somehow the complied and cached library is different from the code as if I make a simple sketch , that contain a loop, not relying on any of the imported libraries, it compiles and runs correctly. When any library is imported the error is displayed. It is not the library but something to do with how the library is linked. At this point I am lost.