Adding 
#include <sys/timeb.h>

to ExternalOutput