SDL2 Undefined references to functions

后端 未结 2 1131
执念已碎
执念已碎 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)
    

提交回复
热议问题