pixie icon indicating copy to clipboard operation
pixie copied to clipboard

Please add MinGW support

Open DiegoJArg opened this issue 2 years ago • 7 comments

I made a very quick attempt. makefile_win.zip

with the following errors.

Unfortunately, it wasn't fixable with adding #include <algorithm> and using namespace std; to imgui.cpp

$ make -f makefile_win
g++ -I. -Wall -DUNICODE -D_UNICODE -g -c imgui.cpp -o obj/imgui.o
imgui.cpp: In static member function 'static void Pixie::ImGui::Input(char*, int, int, int, int, int
)':
imgui.cpp:166:46: error: 'min' was not declared in this scope
  166 |             s_state.keyboardCursorPosition = min((mouseX - textX) / s_state.font->GetCharact
erWidth(), textLength);
      |                                              ^~~
imgui.cpp:211:50: error: 'max' was not declared in this scope
  211 |                 s_state.keyboardCursorPosition = max(s_state.keyboardCursorPosition - 1, 0);

      |                                                  ^~~
imgui.cpp:215:50: error: 'min' was not declared in this scope
  215 |                 s_state.keyboardCursorPosition = min(s_state.keyboardCursorPosition + 1, tex
tLength);
      |                                                  ^~~
imgui.cpp:278:50: error: 'min' was not declared in this scope
  278 |                 s_state.keyboardCursorPosition = min(s_state.keyboardCursorPosition + 1, tex
tBufferLength);
      |                                                  ^~~
make: *** [makefile_win:17: obj/imgui.o] Error 1

DiegoJArg avatar Feb 17 '23 20:02 DiegoJArg

Thanks, I’ll take a look!

samizzo avatar Feb 17 '23 21:02 samizzo

Sorry for the delay @DiegoJArg. I've updated pixie to add a simple makefile for mingw support. Let me know if that works for you. I've also added github actions to test macOS, Windows under msbuild, and Windows under mingw. The macOS and mingw makefiles are very simple for - just debug build, no release config. I'll make them a bit more fully featured soon.

samizzo avatar Feb 26 '23 12:02 samizzo

Hi. Yes, it compiled !! I guess that only the -mwindows was missing for gcc.

pixie_demo.zip

I noted that pixie_demo.exe would only open with msys2. It did not worked from CMD, PowerShell and double-clicking on explorer.

I made slight changes to the new makefile_win:

  • For makefile clean I had to change it to: -rm -rf $(OBJDIR). The '-' sign will ignore errors for busy folder.
  • Removed unnecessary UNICODE defines
  • DEBUG symbols as optional
  • Added symbols stripping to reduce more filesize.

makefile_win.zip

Now that I compiled it, I noted that it uses GDI32 on windows. Similarly, the 'minifb' project has also different backends for framebuffer, including several OGL, but it lacks of a small ImGui headers. Have you tried it? It would be interesting to see but project's strengths joined.

DiegoJArg avatar Feb 27 '23 12:02 DiegoJArg

Thanks for that! Very strange that it wouldn't run. I built from a cmd prompt and it ran successfully. I'll try building from msys2 and see what happens. Thanks for those other changes too. I'm going to set up debug and release builds properly in the makefiles next.

I haven't seen minifb before. It looks a lot more featureful than pixie. OpenGL would definitely be faster (and also make it easier to port to other platforms) but I hadn't had any performance problems personally using GDI. Maybe one day I'll add some other backends though - that would be useful!

samizzo avatar Mar 02 '23 11:03 samizzo

Btw I used the standalone mingw build here https://www.mingw-w64.org/downloads/#mingw-builds which doesn't seem to come with a shell. I'm now installing msys2 and mingw within that using pacman which sounds more like your build environment.

samizzo avatar Mar 02 '23 12:03 samizzo

Are these the errors you got when double clicking? image image

Looks like when building with the gcc installed inside msys it links against some dlls which is unfortunate. I'll look into that.

samizzo avatar Mar 02 '23 12:03 samizzo

Ok I've made a bunch of fixes for this and added debug/release configs. I also renamed the makefile to makefile_mingw. You can build debug with make -f makefile_mingw and release with make -f makefile_mingw CONFIG=release.

I'd rather not add the symbol stripping as I prefer to have symbols available during builds. I'll leave that up to the end user as imho it really belongs in a packaging script rather than the makefile.

samizzo avatar Mar 02 '23 13:03 samizzo