SDL 2 on Windows and MinGW Setup: Issue with tutorial

  • Rashio2017
    Likes 0

    Problem Description

    In regards to this tutorial, https://www.youtube.com/watch?v=ybYMOKEW9IY&t=304s , when I run the compilation through cmd using the exact same filenames and directories as in the tutorial, it works as expected. When I try to make the makefile just as in the tutorial, I get an error from cmd. 

        g++: error: unrecognized command line option ‘-W1,-subsystem,windows’

        Makefile:6: recipe for target ‘all’ failed

        mingw32-make.exe: *** [all] Error 1

    How do I get the makefile to work? 

  • Sonar Systems admin
    Likes 0

    What verions of eveything are you using?

  • Rashio2017
    Likes 0

    Windows 8.1, SDL2 Development library 2.0.7 and the latest version of MinGW, downloaded only yesterday 28/12/2017

  • Sonar Systems admin
    Likes 0

    Try Windows 10

  • Rashio2017
    Likes 0

    Windows 10 is not an option for me, is there any other solution you could suggest?

  • Sonar Systems admin
    Likes 0

    Try the setup process again, sometimes it doesn’t work straight away

  • mrstanlez
    Likes 0

    My code in codeblocks:

    #include <iostream>
    #include <GL/glew.h>
    #include <SDL2/SDL.h>
    #include <SDL2/SDL_opengl.h>

    const GLint WIDTH = 800, HEIGHT = 600;

    int main(int argc, char* args[])
    {
      SDL_Init(SDL_INIT_EVERYTHING);
      SDL_GL_SetAttribute( SDL_GL_CONTEXT_PROFILE_MASK, SDL_GL_CONTEXT_PROFILE_CORE );   SDL_GL_SetAttribute( SDL_GL_CONTEXT_MAJOR_VERSION, 3 );
      SDL_GL_SetAttribute(   SDL_GL_CONTEXT_MINOR_VERSION, 3 );
      SDL_GL_SetAttribute( SDL_GL_STENCIL_SIZE, 8);
     
      SDL_Window *window = SDL_CreateWindow("SDL OpenGL window", 0,0, WIDTH, HEIGHT,                SDL_WINDOW_OPENGL);
     
      SDL_GLContext context = SDL_GL_CreateContext( window );
      glewExperimental = GL_TRUE;
      if(   GLEW_OK != glewInit() )
      { std::cout << "Problem GLEW" << std::endl; return EXIT_FAILURE; }

      glViewport( 0, 0, WIDTH, HEIGHT);
      SDL_Event windowEvent;

      while(true)
      {
         if(SDL_PollEvent( &windowEvent))
         {
            if( SDL_QUIT == windowEvent.type) { break; }
         }
         glClearColor( 0.2f, 0.3f, 0.3f, 1.0f);
         glClear( GL_COLOR_BUFFER_BIT); // draw OpenGL SDL_GL_SwapWindow( window );
      }

      SDL_GL_DeleteContext( context );
      SDL_DestroyWindow( window );
      SDL_Quit(); return EXIT_SUCCESS;
    }

     

    I get Errors: undefined reference to 'glewExperimental' and etc. undefined reference to glViewport@16....


  • Sonar Systems admin
    Likes 0

    Try the code from the github page.

Login to reply