Précédent   Forum du club des développeurs et IT Pro > Applications > Développement 2D, 3D et Jeux > API graphiques > SDL
SDL Forum d'entraide sur l'API SDL. Avant de poster -> FAQ SDL
Partagez cette discussion sur d'autres réseaux sociaux : Viadeo Twitter Google Facebook Digg Delicious MySpace Yahoo
Réponse
 
Outils de la discussion
Publicité
'
Vieux 04/07/2012, 15h31   #1
bactria
Invité de passage
 
Homme
Inscription : janvier 2012
Messages : 7
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations forums :
Inscription : janvier 2012
Messages : 7
Points : 1
Points : 1
Par défaut Problème de compilation SDL

Bonjour,
je suis en train d'écrire un jeu avec opengl 4.0, et j'ai décidé que j'utiliserais sdl pour la création de fenêtre, gestion des touches et de la souris, etc...
Le problème c'est qu'après avoir débuggué une première version de test, je me rends compte qu'aucune des fonction sdl n'est reconnues (en fait, non pas tout à fait, je crois que je n'ai eu aucun message d'erreurs pour SDL_GL_SetAttribute, par exemple).
J'ai donc essayé de remonter à la source du problème, et j'ai isolée et simplifiée la partie du code fisant intervenir des fonctions sdl, et j'ai même essayé, en désespoir de cause, de réinstaller plusieurs fois la bibliothèque (j'utilise apt-get pour l'installer, et j'ai les bibliothèques suivantes: libsdl1.2-dev, libsdl1.2debian, libsdl-image1.2, libsdl1.2-dbg), rien n'y fait.
Voilà le code ultra simplifié pour tester le compilage de la sdl:

main.cpp:
Code :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 
#include <SDL/SDL.h>
#include <string>
 
class Window
{
	public:
		Window(std::string windowTitle, int width, int height);
		~Window();
	private:
		SDL_Window * m_mainwindow; 
		SDL_GLContext m_maincontext;
		int m_width;
		int m_height;
};
 
Window::Window(std::string windowTitle, int width, int height)
{
	m_width = width;
    m_height = height;
 
    //~ if (SDL_Init(SDL_INIT_VIDEO) < 0)
        //~ exitOnError("fail to initialize the SDL window: %s", SDL_GetError());
 
 
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MAJOR_VERSION, 4);
    SDL_GL_SetAttribute(SDL_GL_CONTEXT_MINOR_VERSION, 0);
 
    SDL_GL_SetAttribute(SDL_GL_DOUBLEBUFFER, 1);
    SDL_GL_SetAttribute(SDL_GL_DEPTH_SIZE, 24);
 
    m_mainwindow = SDL_CreateWindow(windowTitle, SDL_WINDOWPOS_CENTERED, SDL_WINDOWPOS_CENTERED,
        m_width, m_height, SDL_WINDOW_OPENGL | SDL_WINDOW_SHOWN | SDL_WINDOW_RESIZABLE);
    //~ if (!m_mainwindow)
        //~ exitOnError("Unable to create window: %s", SDL_GetError());
   m_maincontext = SDL_GL_CreateContext(m_maincontext);
 
    SDL_GL_SetSwapInterval(1);
}
Window::~Window()
{
    SDL_GL_DeleteContext(m_maincontext);
    SDL_DestroyWindow(m_mainwindow);
    SDL_Quit();		
}
 
int main() 
{	
	Window window("Space Game", 512, 512);
 
	//~ Scene test();
	//~ test.mainLoop();
 
	return 0;
}
Voilà le code d'arreur que me retourne le compilo (g++):
main.cpp:11:3: erreur: ‘SDL_Window’ does not name a type
main.cpp:12:3: erreur: ‘SDL_GLContext’ does not name a type
main.cpp: In constructor ‘Window::Window(std::string, int, int)’:
main.cpp:26:25: erreur: ‘SDL_GL_CONTEXT_MAJOR_VERSION’ was not declared in this scope
main.cpp:27:25: erreur: ‘SDL_GL_CONTEXT_MINOR_VERSION’ was not declared in this scope
main.cpp:32:5: erreur: ‘m_mainwindow’ was not declared in this scope
main.cpp:32:50: erreur: ‘SDL_WINDOWPOS_CENTERED’ was not declared in this scope
main.cpp:33:28: erreur: ‘SDL_WINDOW_OPENGL’ was not declared in this scope
main.cpp:33:48: erreur: ‘SDL_WINDOW_SHOWN’ was not declared in this scope
main.cpp:33:67: erreur: ‘SDL_WINDOW_RESIZABLE’ was not declared in this scope
main.cpp:33:87: erreur: ‘SDL_CreateWindow’ was not declared in this scope
main.cpp:36:4: erreur: ‘m_maincontext’ was not declared in this scope
main.cpp:36:54: erreur: ‘SDL_GL_CreateContext’ was not declared in this scope
main.cpp:38:29: erreur: ‘SDL_GL_SetSwapInterval’ was not declared in this scope
main.cpp: In destructor ‘Window::~Window()’:
main.cpp:42:26: erreur: ‘m_maincontext’ was not declared in this scope
main.cpp:42:39: erreur: ‘SDL_GL_DeleteContext’ was not declared in this scope
main.cpp:43:23: erreur: ‘m_mainwindow’ was not declared in this scope
main.cpp:43:35: erreur: ‘SDL_DestroyWindow’ was not declared in this scope

Et enfin, voilà les comment je compile mon fichier main.cpp:
g++ main.cpp -o test $(sdl-config --cflags --libs)


J'ajouterais que j'ai même essayé de copier tel quel le code mit en exemple sur le site même de SDL (et qu'on peut voir en bas de page sur ce lien: http://wiki.libsdl.org/moin.cgi/SDL_...SDL\_Window%29) mais que j'ai toujours a peu près les même erreurs.
J'ai aussi essayé de ne pas utiliser sdl-config et de rentrer les options d'edition de liens moi-même lors de la compilation (avec -lSDL, -lSDL-main, etc...) mais que rien n'y fait.

Pour finir je dirais que j'ai fouillé le fichier SDL.h et tout les autres qui sont donné en lien, et que je n'y ait trouvé aucune mention à la fonction SDL_CreateWindow, par exemple.
Est-ce parce que cette fonction fait appelle à une bibliothèque supplémentaire, et que c'est de là que viendrais mon erreur?
Ou encore autre chose?

J'avaoue que cette histoire commence à me gonfler sérieusement.
Merci d'avance de votre réponse.
bactria est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 04/07/2012, 16h51   #2
edgarjacobs
Membre éclairé
 
Homme
Développeur informatique
Inscription : mai 2011
Messages : 206
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 53
Localisation : Belgique

Informations professionnelles :
Activité : Développeur informatique

Informations forums :
Inscription : mai 2011
Messages : 206
Points : 326
Points : 326
Il me semble que SDL_CreateWindow n'existe qu'à partir de la version 2 de SDL, or je vois que tes libs ont des versions 1.2 ...

Ne m'en demande pas plus, je n'utilise pas la version 2 de SDL.

Edgar.
edgarjacobs est déconnecté   Envoyer un message privé Réponse avec citation 10
Vieux 04/07/2012, 23h45   #3
bactria
Invité de passage
 
Homme
Inscription : janvier 2012
Messages : 7
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations forums :
Inscription : janvier 2012
Messages : 7
Points : 1
Points : 1
A vrai dire c'est une fonction que j'ai trouvé sur wiki officiel d'OpenGL
Apparement, ils disent qu'ils utilisent la version 1.3 de SDL, mais je ne l'ai trouvée nulle part
bactria est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/07/2012, 14h50   #4
edgarjacobs
Membre éclairé
 
Homme
Développeur informatique
Inscription : mai 2011
Messages : 206
Détails du profil
Informations personnelles :
Sexe : Homme
Âge : 53
Localisation : Belgique

Informations professionnelles :
Activité : Développeur informatique

Informations forums :
Inscription : mai 2011
Messages : 206
Points : 326
Points : 326
Voilà un lien qui te permettra sans doute de trouver la SDL 1.3, qui, d'après ce que j'ai compris, est une version intermédiaire entre la 1.2 et la 2.0 (qui elle, est toujours en développement): http://immersedcode.org/2011/4/6/sdl13-intro/ (Site officiel : http://www.libsdl.org/hg.php )

Edgar.
edgarjacobs est déconnecté   Envoyer un message privé Réponse avec citation 00
Vieux 05/07/2012, 22h28   #5
bactria
Invité de passage
 
Homme
Inscription : janvier 2012
Messages : 7
Détails du profil
Informations personnelles :
Sexe : Homme
Localisation : France

Informations forums :
Inscription : janvier 2012
Messages : 7
Points : 1
Points : 1
Merci beaucoups pour ton aide
bactria est déconnecté   Envoyer un message privé Réponse avec citation 00
Réponse
Outils de la discussion

Navigation rapide


Fuseau horaire GMT +2. Il est actuellement 15h55.


 
 
 
 
Partenaires

Hébergement Web