service-manager-src icon indicating copy to clipboard operation
service-manager-src copied to clipboard

Building for Windows with MinGW-w64

Open brechtsanders opened this issue 1 year ago • 2 comments

In the context of true portability I tried to build service-manager with MinGW-w64+GCC (instead of MSVC). It needed some tweaks, but it seems to work.

If you would like to see the tweaks needed or would like to incorporate them in your source, please find my build recipe at: https://github.com/brechtsanders/winlibs_recipes/blob/main/recipes/service-manager.winlib

Any change using release tags? Or are you considering this library still as experimental/unstable?

brechtsanders avatar Mar 15 '24 08:03 brechtsanders

WinMain() is only necessary for Windows applications, not console apps. A quick Google search turns up that using -mconsole when compiling should work.

Release tags are unnecessary. CubicleSoft generally only releases stable, ready-to-use software. If you are concerned about BC breaks and the like:

https://cubiclesoft.com/compatibility-policies/

cubiclesoft avatar May 04 '24 16:05 cubiclesoft

Since you are not using main() but rather _tmain() - which is not compatible with MinGW/MinGW-w64 - and it's building for Unicode just adding -mconsole doesn't quite fix it.

That's why I used this tweak to get it to build:

patch -ulbf servicemanager.cpp << EOF
@@ -721,2 +721,12 @@

+#ifdef __MINGW32__
+int _tmain(int argc, TCHAR **argv);
+int APIENTRY wWinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, TCHAR* lpCmdLine, int nCmdShow)
+{
+       int argc;
+       TCHAR** argv = CommandLineToArgvW(lpCmdLine, &argc);
+       return _tmain(argc, argv);
+}
+#endif
+
 int _tmain(int argc, TCHAR **argv)
EOF

brechtsanders avatar May 04 '24 19:05 brechtsanders