Search code examples
c++makefilesfmlmingw32wine

Error running .exe compiled with i586-mingw32msvc-g++ and SFML on linux


EDIT: Thanks random downvoter!

EDIT 2: Thanks @πάνταῥεῖ for explaining what was wrong with the question. When running a debugger I get

Program received signal SIGSEGV, Segmentation fault.
0x0046f4c6 in ?? ()

EDIT 3: This only happens if I run the cross compiled program. If I compile the program in Windows and run it with WINE, nothing wrong happens.

So well, I'm fighting with WINE and MinGW32 right now. So I have a file, sortem.cpp which is compiled with a Makefile and linked and all from that Makefile.

sortem.cpp

#include <windows.h>
#include <iostream>
#include <string>
#include <SFML/System.hpp>
#include <SFML/Window.hpp>
#include <SFML/Audio.hpp>
#include <SFML/Graphics.hpp>

int main ()
{
    sf::RenderWindow window;
    window.create(sf::VideoMode(720,480),"Sort 'em!");
    while (window.isOpen())
    {
        sf::Event event;
        while (window.pollEvent(event))
            {
                window.clear();
                switch (event.type)
                {
                    case sf::Event::Closed:
                        window.close();
                }
                window.display();
            }
    }
    return 0;
}

Makefile

LD = ../bin
LIBS= $(LD)/sfml-window-2.dll $(LD)/sfml-system-2.dll $(LD)/sfml-graphics-2.dll $(LD)/sfml-network-2.dll $(LD)/sfml-audio-2.dll
OBJECTS= sortem.o
CXX= i586-mingw32msvc-g++
all: sortem.exe

sortem.exe: $(OBJECTS)
     $(CXX) -o ../bin/sortem.exe $(OBJECTS) $(LIBS)

%.o: %.cpp 
    $(CXX) -c $<

clean:
     rm *.o 

So the program compiles perfectly, but when running sortem.exe with WINE, it says the program must exit. I click "Show details" and this pops up. Unhandled exception: page fault on write access to 0x00000000 in 32-bit code (0x0046f4c6).and a lot of hexdumps. I really don't know what I'm doing wrong, maybe the SFML libraries aren't up to date? But that'd give me a compile error, not a runtime error... Thanks a lot for the help, guys.


Solution

  • The libraries were compiled with MinGW GCC 4.7.1 and I was trying to compile my program with MinGW GCC 4.8.1, downgraded thanks to a friend and back online it is. Thanks you guys all for having shown me how to debug. Peace