E:/Code_R/test/main.c: In function 'SDL_main': E:/Code_R/test/main.c:4:1: error: number of arguments doesn't match prototype 4 | int main() { | ^~~ In file included from E:/C_Lib/SDL2-2.26.5/x86_64-w64-mingw32/include/SDL2/SDL.h:32, from E:/Code_R/test/main.c:2: E:/C_Lib/SDL2-2.26.5/x86_64-w64-mingw32/include/SDL2/SDL_main.h:155:29: error: prototype declaration 155 | extern SDLMAIN_DECLSPEC int SDL_main(int argc, char *argv[]); | ^~~~~~~~ ninja: build stopped: subcommand failed.
这是由于SDL的接管机制,将main()如下重定义:
1 2
#define main SDL_main extern SDLMAIN_DECLSPEC intSDL_main(int argc, char *argv[]);
E:\CLion 2022.1.2\bin\mingw\bin/ld.exe: /Users/valve/release/SDL2/SDL2-2.26.5-source/foo-x64/../src/main/windows/SDL_windows_main.c:73: undefined reference to `SDL_memcpy' E:\CLion 2022.1.2\bin\mingw\bin/ld.exe: /Users/valve/release/SDL2/SDL2-2.26.5-source/foo-x64/../src/main/windows/SDL_windows_main.c:74: undefined reference to `SDL_free' E:\CLion 2022.1.2\bin\mingw\bin/ld.exe: /Users/valve/release/SDL2/SDL2-2.26.5-source/foo-x64/../src/main/windows/SDL_windows_main.c:64: undefined reference to `SDL_wcslen' E:\CLion 2022.1.2\bin\mingw\bin/ld.exe: /Users/valve/release/SDL2/SDL2-2.26.5-source/foo-x64/../src/main/windows/SDL_windows_main.c:64: undefined reference to `SDL_iconv_string' E:\CLion 2022.1.2\bin\mingw\bin/ld.exe: E:/C_Lib/SDL2-2.26.5/x86_64-w64-mingw32/lib/libSDL2main.a(SDL_windows_main.o): in function `OutOfMemory': /Users/valve/release/SDL2/SDL2-2.26.5-source/foo-x64/../src/main/windows/SDL_windows_main.c:26: undefined reference to `SDL_ShowSimpleMessageBox' E:\CLion 2022.1.2\bin\mingw\bin/ld.exe: E:/C_Lib/SDL2-2.26.5/x86_64-w64-mingw32/lib/libSDL2main.a(SDL_windows_main.o): in function `main_getcmdline': /Users/valve/release/SDL2/SDL2-2.26.5-source/foo-x64/../src/main/windows/SDL_windows_main.c:79: undefined reference to `SDL_SetMainReady'
CMake Error at CMakeLists.txt:10 (find_package): By not providing "FindSDL2.cmake" in CMAKE_MODULE_PATH this project has asked CMake to find a package configuration file provided by "SDL2", but CMake did not find one.
Could not find a package configuration file provided by "SDL2" with any of the following names:
SDL2Config.cmake sdl2-config.cmake
Add the installation prefix of "SDL2" to CMAKE_PREFIX_PATH or set "SDL2_DIR" to a directory containing one of the above files. If "SDL2" provides a separate development package or SDK, be sure it has been installed.