Flips icon indicating copy to clipboard operation
Flips copied to clipboard

Will not compile on Windows with MinGW

Open LoganSchmalz opened this issue 4 years ago • 13 comments

I needed the new version of the patcher to fix the "won't create patch with files that are 16mb" 1.31 bug (the link to download on the old issue seems to be down), but I absolutely cannot get the patcher to compile on Windows. MinGW reports that _wtoi, _wcsicmp, and _wcsdup are not declared in scope back from the define in flips.h. I've tried messing with the header unsuccessfully. I can confirm that it is compiling with the FLIPS_WINDOWS option (so these should be working), but I can't figure out much beyond that. I also can confirm that these functions are properly functioning on my computer in programs I wrote to test them quickly, including with #define.

LoganSchmalz avatar May 26 '20 05:05 LoganSchmalz

Read over #26 and see if that helps. Notably the final comment where I listed the working commands.

Sanaki avatar May 26 '20 07:05 Sanaki

mingw works for me, but there are many mingw variants.

Check if it works better if you add #include <string.h> and #include <stdlib.h> beside the #include <stdio.h> on line 63.

Alternatively, try deleting the three #defines on lines 67-69.

Alcaro avatar May 26 '20 14:05 Alcaro

@Sanaki's suggestion worked, as well as setting up MinGW-w64 rather than the original MinGW.

Additionally, the original MinGW has a different definition for swprintf() due to Microsoft's old implementation that did not comply with the ISO-C standard, which means it still won't compile even using the alternative commands, so MinGW-w64 must be used (I was honestly unaware there was more than one MinGW variant, so hopefully this helps someone).

For whatever reason, I still cannot get it to compile via the makefile. Perhaps someone more experienced than I am can figure out how to make it work.

LoganSchmalz avatar May 27 '20 01:05 LoganSchmalz

Hi, I have the exact same problem and all the solutions proposed here and in #26 didn't work...

Niilyx avatar May 23 '21 13:05 Niilyx

You tried the commands in the final post there and it didn't work? What -did- happen?

Sanaki avatar May 23 '21 13:05 Sanaki

You tried the commands in the final post there and it didn't work? What -did- happen?

Yeah no, at first at tried to compile this stuff without the required libraries (I don't know crap about compiling stuff in C++). Then I tried a multitude of useless solutions, then the last commands in #26 and now I have my binary. Thank you for your help!

Niilyx avatar May 24 '21 14:05 Niilyx

Trying to compile on MSYS2 MINGW64 and getting

ld.exe: C:\msys64\tmp\ccNH0hGd.o:flips.cpp:(.text+0x83): multiple definition of `.weak.__cxa_pure_virtual._ZN4fileD2Ev'

13xforever avatar Feb 11 '22 11:02 13xforever

Isn't the point of weak symbols that they can be defined multiple times?

Maybe that specific one isn't as weak as it should be. Try removing line 14 from flips.cpp.

Alcaro avatar Feb 11 '22 11:02 Alcaro

Thanks, it works. I feel stupid, I just automatically scrolled to the actual code and didn't notice the extern definition

13xforever avatar Feb 11 '22 11:02 13xforever

On MSYS2 Mingw64:

/c/Users/me/work_mingw/Flips/flips-gtk.cpp: In function ‘int main(int, char**)’:
/c/Users/me/work_mingw/Flips/flips-gtk.cpp:1055:47: error: ‘F_OK’ was not declared in this scope
 1055 |         isFlatpak = (access("/.flatpak-info", F_OK) == 0);
      |                                               ^~~~
/c/Users/me/work_mingw/Flips/flips-gtk.cpp:1055:22: error: ‘access’ was not declared in this scope
 1055 |         isFlatpak = (access("/.flatpak-info", F_OK) == 0);
      |                      ^~~~~~
make: *** [Makefile:95: flips] Error 1

I tried manually defining FLIPS_WINDOWS in flips.h, but that just made matters worse. I will admit, my MSYS install might be borked.

bitrot-alpha avatar Aug 19 '22 21:08 bitrot-alpha

Either your msys installation is borked, or Flips is. And I already know Flips is borked in several ways, so let's assume there's only one bork going on.

Are you trying to compile with make.sh? That one is only intended for Linux binaries. If you want a Windows binary, you're supposed to use the Makefile, or grab the binary from SMW Central.

Though I will agree that error is quite unhelpful. I'd welcome a PR to either error out earlier or add Windows support to make.sh, but I don't have any msys on my machine (I compile my Windows binaries with a mingw installed in Wine, as seen in make-maintainer.sh), so I can't produce one myself.

Alcaro avatar Aug 19 '22 21:08 Alcaro

I tried using make which produced the above error. I also tried @Sanaki's solution, and that produced an exe, but when trying to run it outside of the msys terminal, it complains about missing mingw dlls. If I get some spare time, you may yet see a PR to fix whatever's wrong, or another follow-up with what my actual issue was.

bitrot-alpha avatar Aug 21 '22 11:08 bitrot-alpha