0

I've been trying to configure pretty much any kind of API for minGW, using Eclipse on windows 10 for about 2-3 days. I've been trying to google the answers but I can't seem to find the correct one. I was just hoping you could provide some clarification.

Source code:

#include <iostream>
#include <SDL.h>
using namespace std;

int main() {
    if(SDL_Init(SDL_INIT_VIDEO) < 0){
            cout << "SDL_INIT Failed" << endl;
            return 1;
        }
        cout << "SDL_INIT Succeded!" << endl;

        SDL_Quit();
    return 0;
}

When I edit the C++ project/properties/build, I changed the debug to all configs, under: C++ build/settings/MinGW C++ Linker/lib I said Library search path(-L) will look in C:\Users\lonxk\Desktop\SDL2\SDL\lib\win32. That folder has my SDL2.dill, SDKL2.lib, SDL2main.lib. Under my Libraries(-l) I listed SDL2, and SDL2main. When I place .lib after them and build the program it says "mingw32/bin/ld.exe: cannot find -lSDL2.lib", and cannot find SDL2main.lib. When I place then under my Libraries(-l) as SDL2 and SDL2main it has following error undefined reference to `WinMain@16'. Under my GCC C++ Compiler/include/Include Path(-l) I have "C:\Users\lonxk\Desktop\SDL2\SDL\include". And in the include folder I have all my .h file types. Also when I try to run the program it says SDLTest.exe not found. Once I remove my include SDL.h from the top and try to run the program as "Hello World" it works. So the .cpp is still functioning. Finally in my System Environmental Variables I added, "C:\Users\lonxk\Desktop\SDL2\SDL\lib\win32" because that's where the .dll file is. Does anyone have any idea what the issue could be?

  • Correct library order is `-lmingw32 -lSDL2main -lSDL2`. Correct `main` signature is `int main(int argc, char **argv)`. I believe it is covered by SDL [FAQ](https://wiki.libsdl.org/FAQWindows) – keltar Mar 09 '17 at 15:38
  • @keltar I figured it out by bypassing MinGW completely. I then read all the header(.h) files in the include folder of SDL. I found a reference in SDL_Main.h that spoke about configuring SDL for windows stating that SDL provides it's on main function (main();) and if I wanted to use my own I would need to #define SDL_MAIN_HANDLED before I #include "SDL.h" – Tyler Klein Mar 11 '17 at 07:50

0 Answers0