我试图第一次使用SDL2,并且我进行编译,并且库有一些错误原因
In function `main':
main.cpp:(.text+0x25): undefined reference to `SDL_Init'
main.cpp:(.text+0x31): undefined reference to `SDL_GetError'
main.cpp:(.text+0x80): undefined reference to `SDL_CreateWindow'
main.cpp:(.text+0x90): undefined reference to `SDL_GetError'
main.cpp:(.text+0xc1): undefined reference to `SDL_GetWindowSurface'
main.cpp:(.text+0xe4): undefined reference to `SDL_MapRGB'
main.cpp:(.text+0xf7): undefined reference to `SDL_FillRect'
main.cpp:(.text+0x103): undefined reference to `SDL_UpdateWindowSurface'
main.cpp:(.text+0x10d): undefined reference to `SDL_Delay'
main.cpp:(.text+0x119): undefined reference to `SDL_DestroyWindow'
main.cpp:(.text+0x11e): undefined reference to `SDL_Quit'
collect2: error: ld returned 1 exit status
使用我写的库
#include <SDL2/SDL.h>
也许您应该将dll放在exe文件夹中,或包括静态库。在这里,您仅包含头文件,该头文件具有声明且没有定义,因此编译器不知道这些函数的作用。