2

This test program should create a blank window that stays open until you x-it-out. I copied it from SDL's documentation to make sure it is correct. It can be found here.

// Example program:
// Using SDL2 to create an application window

#include "SDL.h"
#include <stdio.h>

int main(int argc, char* argv[]) {

    SDL_Window *window;                    // Declare a pointer

    SDL_Init(SDL_INIT_VIDEO);              // Initialize SDL2

    // Create an application window with the following settings:
    window = SDL_CreateWindow(
            "An SDL2 window",                  // window title
            SDL_WINDOWPOS_UNDEFINED,           // initial x position
            SDL_WINDOWPOS_UNDEFINED,           // initial y position
            640,                               // width, in pixels
            480,                               // height, in pixels
            SDL_WINDOW_OPENGL                  // flags - see below
    );

    // Check that the window was successfully created
    if (window == NULL) {
        // In the case that the window could not be made...
        printf("Could not create window: %s\n", SDL_GetError());
        return 1;
    }

    //game loop, quitGame to quit
    bool quitGame = false;
    //var for checking events
    SDL_Event event;
    while(!quitGame) {
        //Update particles
        //Draw particles
        //Check for events
        while(SDL_PollEvent(&event)) {
            if(event.type == SDL_QUIT)
                quitGame = true;
        }
    }

    // Close and destroy the window
    SDL_DestroyWindow(window);

    // Clean up
    SDL_Quit();
    return 0;
}

It doesn't create a window and terminates immediately, but gives no errors.

I'm using Eclipse, mingw32, and the latest stable release of SDL2. SDL2's libraries and headers are within a file in my C drive. I am using a 64 bit system. I include the entire folder of SDL2's header files. The only library folder I have linked is the one within the 64 bit part of the SDL2 folder. The libraries I have linked are the ones suggested by HolyBlackCat, (in this order) mingw32, SDL2main, and SDL2. Any help is greatly appreciated. Thanks!

Cole T
  • 29
  • 3
  • Comments are not for extended discussion; this conversation has been [moved to chat](http://chat.stackoverflow.com/rooms/134720/discussion-on-question-by-cole-t-including-sdl-h-causes-undefined-reference-to). – user229044 Feb 03 '17 at 02:00
  • Possible duplicate of [Undefined reference to WinMain@16 when using SDL](http://stackoverflow.com/questions/18115153/undefined-reference-to-winmain16-when-using-sdl) – Brad Allred Feb 03 '17 at 07:06

0 Answers0