MinGW runtime 4.x calls the dirent functions, opendir/readdir/closedir, in its startup code. This pollutes the namespace of, and breaks, application programs that have incompatible or entirely unrelated functions by that name, even if the application didn't include the dirent.h header. For example, a program that defines its own readdir will almost surely break the globbing of command-line arguments, and could even crash.
Please make the startup code call
__readdir, etc. instead, as symbols that begin with two underscores are "reserved", and cannot legitimately appear in an application.