我试过回答类似的问题,但没有解决这个问题。我下载了Visual 2017和SDL2开发库的新安装。然后加载一些示例代码,使用SDL打开窗口进行测试,然后添加包含所有SDL头文件的包含目录,以及添加"SDL2.lib和SDL2main.lib“。然而,每次我尝试构建代码时,它都会向我发出几个错误。我也有一些屏幕截图。任何帮助都将不胜感激。这显示了包含目录的位置,并将其添加到其他包含中。 这显示了构建后的所有错误。
示例窗口代码
#include <SDL.h>
#include <stdio.h>
int main(int argc, char* argv[]) {
SDL_Window *window; // Declare a pointer
SDL_Init(SDL_INIT_VIDEO); // Initialize SDL2
// Create an application window with the following settings:
window = SDL_CreateWindow(
"An SDL2 window", // window title
SDL_WINDOWPOS_UNDEFINED, // initial x position
SDL_WINDOWPOS_UNDEFINED, // initial y position
640, // width, in pixels
480, // height, in pixels
SDL_WINDOW_OPENGL // flags - see below
);
// Check that the window was successfully created
if (window == NULL) {
// In the case that the window could not be made...
printf("Could not create window: %s\n", SDL_GetError());
return 1;
}
// The window is open: could enter program loop here (see SDL_PollEvent())
SDL_Delay(3000); // Pause execution for 3000 milliseconds, for example
// Close and destroy the window
SDL_DestroyWindow(window);
// Clean up
SDL_Quit();
return 0;
}
错误
发布于 2017-09-04 12:40:43
因此,首先,我继续构建调试,这给我带来了问题,解决方案是构建发行版。然后,使用lnk1561,我必须告诉链接器在编译的对象中使用哪些.lib文件,然后添加这个"SDL2.lib;SDL2main.lib;“没有引号来输入额外的依赖项,然后最后添加到系统子系统”/SUBSYSTEM:WINDOWS“。更好的解释可以在这页上看到..。SDL/windows/msvsnet2010u/index.php谢谢大家的帮助!
https://stackoverflow.com/questions/46035303
复制相似问题