SDL_Main or WinMain@16 error

Discussion in 'C++' started by Michael Sgier, Aug 14, 2004.

  1. Hi
    While trying to compile the follwoing example with devC++
    I get errors:

    D:\SDL-1.2.7MingW\lib\libSDLmain.a(SDL_win32_main.o.b)
    (.text+0x34b)
    [Warning] In function `console_main':
    [Linker error] undefined reference to `SDL_SetModuleHandle'
    [Linker error] undefined reference to `SDL_main'
    If I delete the SDL linker I get undefined reference to
    WinMain@16
    Thanks for help. Regards
    Michael
    PS: The links to sdl etc. should be fine tough.



    /* Example of OpenGL rendering through SDL. */

    #include <SDL/SDL.h>
    #include <GL/gl.h>
    #include <stdio.h>
    #include <stdlib.h>

    int main()
    {

    /* Initialize SDL as usual. */
    if (SDL_Init(SDL_INIT_VIDEO) != 0) {
    printf("Error: %s\n", SDL_GetError());
    return 1;
    }

    atexit(SDL_Quit);

    /* Enable OpenGL double buffering. */
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);

    /* Set the color depth (16-bit 565). */
    SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 5);
    SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 6);
    SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 5);

    /* Create a 640x480, 16 bit window with support for
    OpenGL rendering. Unfortunately we won't know
    whether this is hardware accelerated. */
    if (SDL_SetVideoMode(640, 480, 16, SDL_OPENGL) == NULL) {
    printf("Error: %s\n", SDL_GetError());
    return 1;
    }

    /* Set a window title. */
    SDL_WM_SetCaption("OpenGL with SDL!", "OpenGL");

    /* We can now use any OpenGL rendering commands. */
    glViewport(80, 0, 480, 480);
    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glFrustum(-1.0, 1.0, -1.0, 1.0, 1.0, 100.0);
    glClearColor(0, 0, 0, 0);
    glMatrixMode(GL_MODELVIEW);
    glLoadIdentity();
    glClear(GL_COLOR_BUFFER_BIT);
    glBegin(GL_TRIANGLES);
    glColor3f(1.0, 0, 0);
    glVertex3f(0.0, 1.0, -2.0);
    glColor3f(0, 1.0, 0);
    glVertex3f(1.0, -1.0, -2.0);
    glColor3f(0, 0, 1.0);
    glVertex3f(-1.0, -1.0, -2.0);
    glEnd();
    glFlush();

    /* Display the back buffer to the screen. */
    SDL_GL_SwapBuffers();

    /* Wait a few seconds. */
    SDL_Delay(5000);

    return 0;
    }
     
    Michael Sgier, Aug 14, 2004
    #1
    1. Advertising

  2. Michael Sgier

    Roger C Guest

    "Michael Sgier" <> wrote in message
    news:411e85d1$0$4887$...
    > Hi
    > While trying to compile the follwoing example with devC++
    > I get errors:
    >
    > D:\SDL-1.2.7MingW\lib\libSDLmain.a(SDL_win32_main.o.b)
    > (.text+0x34b)
    > [Warning] In function `console_main':
    > [Linker error] undefined reference to `SDL_SetModuleHandle'
    > [Linker error] undefined reference to `SDL_main'
    > If I delete the SDL linker I get undefined reference to
    > WinMain@16
    > Thanks for help. Regards
    > Michael
    > PS: The links to sdl etc. should be fine tough.


    Try including windows.h before any other headers and replace "int main()"
    with "int WINAPI WinMain( HINSTANCE hInstance, HINSTANCE hPrevInstance, PSTR
    lpCmdLine, uint nCmdShow )"
     
    Roger C, Aug 14, 2004
    #2
    1. Advertising

  3. Michael Sgier <> spoke thus:

    > While trying to compile the follwoing example with devC++
    > I get errors:


    > D:\SDL-1.2.7MingW\lib\libSDLmain.a(SDL_win32_main.o.b)
    > (.text+0x34b)
    > [Warning] In function `console_main':
    > [Linker error] undefined reference to `SDL_SetModuleHandle'
    > [Linker error] undefined reference to `SDL_main'
    > If I delete the SDL linker I get undefined reference to
    > WinMain@16
    > Thanks for help. Regards
    > Michael
    > PS: The links to sdl etc. should be fine tough.


    Your post is off-topic for comp.lang.c++. Please visit

    http://www.slack.net/~shiva/welcome.txt
    http://www.parashift.com/c -faq-lite/

    for posting guidelines and frequently asked questions. Thank you.

    --
    Christopher Benson-Manica | I *should* know what I'm talking about - if I
    ataru(at)cyberspace.org | don't, I need to know. Flames welcome.
     
    Christopher Benson-Manica, Aug 16, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. hfk0
    Replies:
    2
    Views:
    21,688
  2. JavaQueries
    Replies:
    1
    Views:
    3,695
    John C. Bollinger
    Mar 1, 2005
  3. Michael Sgier

    sdl_main or WinMain@16 error

    Michael Sgier, Aug 14, 2004, in forum: C++
    Replies:
    1
    Views:
    1,964
    Arttu Valo
    Aug 16, 2004
  4. Helen

    winMain link error

    Helen, Nov 18, 2003, in forum: C Programming
    Replies:
    1
    Views:
    472
    Jack Klein
    Nov 18, 2003
  5. Jrdman

    WinMain()

    Jrdman, Jul 3, 2008, in forum: C Programming
    Replies:
    7
    Views:
    817
    Harald van Dijk
    Jul 3, 2008
Loading...

Share This Page