VS2017配置SDL2

版权声明:本文为YuanChuang文章,未经博主允许转载。 https://blog.csdn.net/zzy1448331580/article/details/89073445

0.x86还是x64看自己的情况

1.把包含文件和库文件复制到项目的路径下面

2.项目 -> 属性 -> VC++目录 设置包含文件和库文件

3.把SDL2.dll复制一份到项目路径下面

4.

#include "SDL.h"

5.

#pragma comment(lib,"x86\\SDL2.lib")
#pragma comment(lib,"x86\\SDL2main.lib")
#pragma comment(lib,"x86\\SDL2test.lib")

OK

测试代码:

#include "SDL.h"
#include <stdlib.h>
#include <stdio.h>
#pragma comment(lib,"x86\\SDL2.lib")
#pragma comment(lib,"x86\\SDL2main.lib")
#pragma comment(lib,"x86\\SDL2test.lib")
int main(int argc, char* argv[]) 
{
	SDL_Window *window;
	SDL_Init(SDL_INIT_EVERYTHING); 
	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
	);

	if (window == NULL) 
	{
		printf("Could not create window: %s\n", SDL_GetError());
		return 1;
	}
	SDL_Delay(3000);
	SDL_DestroyWindow(window);
	SDL_Quit();
	system("pause");
	return 0;
}

猜你喜欢

转载自blog.csdn.net/zzy1448331580/article/details/89073445