At the bottom of the documentation page for timeSetEvent is:
This means that you have to link with Winmm.lib to use that function. Add a library to the link using gcc's -l option:
Library: Use Winmm.lib.
To use the VC compiler with Windows functions, you will need to download the Platform SDK.
gcc -o output -mwindows stuff.o mainfile.c -lwinmm
You can then compile your code with a batch file like this:
This batch file will compile a file dragged onto it. Alternatively, you can replace %1 with the name of one or more files you wish to compile. A list of cl options is available here.
:: This is for VC Toolkit 2003.
call "C:\Program Files\Microsoft Visual C++ Toolkit 2003\vcvars32"
:: Set environment variables for Platform SDK:
SET INCLUDE=%INCLUDE%;C:\Program Files\Microsoft SDK\Include;
SET LIB=%LIB%;C:\Program Files\Microsoft SDK\Lib;
cd /d %0\..
cl /GF /W3 %1 KERNEL32.LIB USER32.LIB