cubiclesoft / service-manager-src

The source code to the world's first cross-platform, open source (MIT or LGPL), programming AND scripting language-agnostic solution to system service development. Binaries:
https://github.com/cubiclesoft/service-manager
17 stars 5 forks source link

Building for Windows with MinGW-w64 #3

Open brechtsanders opened 4 months ago

brechtsanders commented 4 months ago

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?

cubiclesoft commented 2 months ago

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/

brechtsanders commented 2 months ago

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