Reputation: 21
I have tried answers from similarly asked question and non has not fix this problem. I downloaded a fresh install of Visual Studio 2017 and the SDL2 development libraries. Then loaded up some sample code to open a window using SDL to test and then added the include directory containing all the SDL header files, as well as added the "SDL2.lib and SDL2main.lib". However Every-time I try to build the code it spits out several errors at me. I have also include some screen shots. Any help would be much appreciated. This shows where the include directory is located and that it's is added to additional include. This shows all the errors after building.
#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;
}
Upvotes: 0
Views: 5705
Reputation: 21
So first I kept building in debug which gave me problems, the solution is to build release. Then with the lnk1561 I had to tell linker which .lib files to use with the compiled object, then add this "SDL2.lib; SDL2main.lib;" without quotes to input additional dependencies, then finally add to system subsystem "Windows (/SUBSYSTEM:WINDOWS)". Better explanation can be seen on this page... http://lazyfoo.net/tutorials/SDL/01_hello_SDL/windows/msvsnet2010u/index.php Thank you everyone for your help!
Upvotes: 1