Getting started with SDL

Good morning,

I have read a french book dealing with C and SDL 1.2 (openclassroom, site du zero). I would like to use microsoft Visual C 2010 with SDL 2.0 I have understood new functions are used with SDL 2.0.

Here is a short program and the compilation errors

/* programme du site du zero p 313 mn 2017/04/21  */
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>

void pause();

int main(int argc, char *argv[])
{
	SDL_Init(SDL_INIT_VIDEO);
/*	SDL_SetVideoMode(640,480,32,SDL_HWSURFACE);  */

	
	
	
	SDL_Window *screen = SDL_CreateWindow("My Game Window",
                          SDL_WINDOWPOS_UNDEFINED,
                          SDL_WINDOWPOS_UNDEFINED,
                          640, 480,
                          SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL);
						  

	pause();
	SDL_Quit();
	return EXIT_SUCCESS;
}

void pause()
{
	int continuer=1;
	SDL_Event event;
	while (continuer)
	{
		SDL_WaitEvent(&event);
		switch(event.type)
		{
		case SDL_QUIT :
				continuer=0;
		}
	}
}

with the following errors

1>------ Début de la génération : Projet : testsdl, Configuration : Debug Win32 ------
1>  main.c
1>c:\users\clevo\documents\sdl_mixer_2017\projets\essai_01_x86\testsdl\testsdl\main.c(16): error C2275: 'SDL_Window' : utilisation non conforme de ce type comme expression
1>          c:\program files (x86)\microsoft visual studio 10.0\vc\include\sdl\sdl_video.h(90) : voir la déclaration de 'SDL_Window'
1>c:\users\clevo\documents\sdl_mixer_2017\projets\essai_01_x86\testsdl\testsdl\main.c(16): error C2065: 'screen' : identificateur non déclaré
========== Génération : 0 a réussi, 1 a échoué, 0 mis à jour, 0 a été ignoré ==========

An other attempt with even less instructions

/* programme du site du zero p 313 mn 2017/04/21  */
#include <stdlib.h>
#include <stdio.h>
#include <SDL/SDL.h>

void pause();

int main(int argc, char *argv[])
{
	SDL_Init(SDL_INIT_VIDEO);
/*	SDL_SetVideoMode(640,480,32,SDL_HWSURFACE);  */

	
	
	/*
	SDL_Window *screen = SDL_CreateWindow("My Game Window",
                          SDL_WINDOWPOS_UNDEFINED,
                          SDL_WINDOWPOS_UNDEFINED,
                          640, 480,
                          SDL_WINDOW_FULLSCREEN | SDL_WINDOW_OPENGL);
						  
*/
	pause();
	SDL_Quit();
	return EXIT_SUCCESS;
}

void pause()
{
	int continuer=1;
	SDL_Event event;
	while (continuer)
	{
		SDL_WaitEvent(&event);
		switch(event.type)
		{
		case SDL_QUIT :
				continuer=0;
		}
	}
}

with the errors

1>------ Début de la génération : Projet : testsdl, Configuration : Debug Win32 ------
1>  main.c
1>LINK : fatal error LNK1123: échec lors de la conversion en fichier COFF : fichier non valide ou endommagé
========== Génération : 0 a réussi, 1 a échoué, 0 mis à jour, 0 a été ignoré ==========

Coul’d you help me to obtain a very short program without error, using Visual C++ Express 2010 (with C langage) on Windows 7 ?

Is your SDL.h from SDL 2.0, or SDL 1.2?

I thank you very much to try to help me.

The SDL.h file was loaded from SDL2-devel-2.5-VC.zip/SDL2-2.0.5/include.

The content of the include directory has been copyed in

Program Files(x86)/Microsoft Visual Studio 10.0/VC/include/SDL/

The SDL2.dll (for x86) is in the essai_01_x86 directory and also in the essai_01_x86/testsdl directory (where testsdl.sln was created by Visual Studio 2010.

I have just tried with the SDL2.dll for x64, and I obtain the same compilation errors, but perhaps the SDL2.lib and SDL2main.lib and SDL2test.lib (from x86 folder) are not the good ones (copyed in VC/lib) ?

I have no directory VC in Program Files/Microsoft Visual Studio 10.0 but a Common7 directory, so y have copyed the .h and .lib files in the corresponding folders under the Program Files (x86) directory.

The compilation options in Visual C++ Express are

Bibliotheque runtime : DLL multithread (/MD)
Compiler comme code C (/TC)
Editeur de lien Entree SDL2.lib;SDL2main.lib
Systeme SousSysteme Windows

It’s very nice to try to help me.

Marc