0

I'm writing a simple roguelike, and I was compiling statically to test, but I found that the program a) crashes when input is given, and b) does not seem to randomize at all when I compiled with MinGW. I switched over to Cygwin to check it out, and found that the statically-compiled version with Cygwin performed exactly as expected. I used the same commands for both: g++ -c FILE_NAME -std=c++14 -lncurses for each source file, then g++ -static -o dngn OBJECTS -std=c++14 -lncurses to link the final build.

The MinGW build: mingw.png

The Cygwin build: cygwin.png

Both images are screengrabs of it running with the respective compiler

Community
  • 1
  • 1
penelope
  • 1
  • 2
  • 2
    They say a picture is worth a thousand words, but it's not a replacement for your actual code. Take some time and put together a [mcve] that demonstrates the problem. It's often something simple like an uninitialized variable that you may find while trying to find the problem spot. You could also consider using a debugger which will tell you exactly where the crash is and allow you to examine what's going on at the time of the crash. – Retired Ninja Sep 08 '18 at 01:54
  • The problem is, the same code works perfectly on Ubuntu and Cygwin, and not on MinGW. I don't even know how to start reducing it down. Are there any common things that cause defects of the header/segfaults only in MinGW? – penelope Sep 08 '18 at 01:56
  • 1
    Yes, undefined behavior or differences in implementation defined behavior. A debugger is your best bet. – Retired Ninja Sep 08 '18 at 01:58
  • Unfortunately, when I run `gdb`, even with a breakpoint at the beginning of `main`, it simply shows the same screen in mingw.png, and freezes. – penelope Sep 08 '18 at 02:07
  • This cannot be answered reasonable without code. Hence again, please, provide a [mcve]. If your code is too large you should reduce it until it contains the only necessary lines to reproduce your issue. Concerning this, [E. Lippert: How to debug small programs](https://ericlippert.com/2014/03/05/how-to-debug-small-programs/) is worth reading. – Scheff's Cat Sep 08 '18 at 08:59
  • Does it works if you remove `--static` ? I noticed in the past that g++ and static are not always handling well some type of exception. – matzeri Sep 08 '18 at 10:30
  • Try rebuilding everything with -Wall -Wextras --pedantic -O2. Get rid of all the warnings (really, all of them!). Try on all platforms. Note any version differences between your compilers in each platform. – Doug Henderson Sep 09 '18 at 05:39

0 Answers0