我正在尝试使用eclipse(linux)设置SDL2,但eclipse只会抛出错误"未定义的引用"。我在谷歌上发现我需要添加这个标志" -lSDL2"到链接器。所以我转到Project Settings -> C/C++ Build -> Settings -> GCC Linker -> Miscellaneous
并将其添加到Linker标志中。但它没有用,eclipse抛出这个错误:
Building target: test_c
Invoking: GCC C Linker
gcc -lSDL2 -o "test_c" ./main.o
./main.o: In function `main':
/home/nimmi/Documents/workspace/test_c/Debug/../main.c:7: undefined reference to `SDL_Init'
makefile:29: recipe for target 'test_c' failed
/home/nimmi/Documents/workspace/test_c/Debug/../main.c:11: undefined reference to `SDL_CreateWindow'
/home/nimmi/Documents/workspace/test_c/Debug/../main.c:20: undefined reference to `SDL_UpdateWindowSurface'
/home/nimmi/Documents/workspace/test_c/Debug/../main.c:21: undefined reference to `SDL_Delay'
collect2: error: ld returned 1 exit status
make: *** [test_c] Error 1
12:17:09 Build Finished (took 172ms)