SDL2 Undefined references to functions

后端 未结 2 1130
执念已碎
执念已碎 2021-01-21 09:10

I\'m trying to set up a C++ project that builds on MinGW and uses SDL. When i try to compile my program, g++ says undefined reference to \'SDL_Function\' for each S

相关标签:
2条回答
  • 2021-01-21 09:41

    Try to change the sequence of the input params:

    I've stumbled over this before (on Linux):

    This call produces an error:

    g++ $(pkg-config --cflags --libs sdl2) sdl2test.cpp 
    
    sdl2test.cpp:(.text+0x11): undefined reference to `SDL_Init'
    sdl2test.cpp:(.text+0x20): undefined reference to `SDL_GetError'
    sdl2test.cpp:(.text+0x34): undefined reference to `SDL_Quit'
    

    This works:

    g++ sdl2test.cpp $(pkg-config --cflags --libs sdl2)
    
    0 讨论(0)
  • 2021-01-21 09:45

    I changed the sequence of the input parameters and it worked, put SDL2main before SLD2.

    0 讨论(0)
提交回复
热议问题