Used sources from getopt-win32 repo and setupped it to compile with MinGW to static (lib[...].a) & dynamic ([...].dll) libraries.
Just run build.bat and wait for comiling and linking libraries. Out libraries files contain in build/ folder.
Copy getopt.h to your compiler include path (folder).
You need only to copy libgetopt.a to MinGW libraries path (folder).
It has the same steps like static linking, but also has some additions.
It's recommended to copy getopt.dll to both compiler libraries path (folder) and your application folder (where contains you .exe program), overwise you can get "library not found"-like Windows error when you run your program.