It builds properly wcmd executable. But running it I get a Segmentation fault (core dumped). When running it using gdb, I find the exception before main in libshell32.so library.
What am I going wrong ?
you should really read wine.codeweavers.com/docs/winelib-user/
what's you're missing is the complete init sequence of a winelib application you no longer can directly link your .c files directly
you need at least to initialize your application's module before your main is entered (it's why you don't get a decent output handle)
either use winemaker on your source files (winemaker is a dedicated tool designed to help you create a winelib project)
when you tried to use the wcmd Makefile, you used in fact Makefile.in, which is a template and is expanded into a real Makefile (which is pretty much more complicated than what you wrote)
so, winemaker is really your friend here
A+