Bsoir :3

Voici le singleton en question:

Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
 
class Threads: public Singleton<Threads>
{
    friend class Singleton<Threads>;
    public:
        Threads();
        ~Threads();
        static SDL_cond *GUIEventWait() { return _guiEventWait; }
        static SDL_mutex *GUIEventLock() { return _guiEventLock; }
    protected:
    private:
        SDL_Thread* _gui;
        static SDL_cond *_guiEventWait;
        static SDL_mutex *_guiEventLock;
};
 
SDL_cond *Threads::_guiEventWait;// = SDL_CreateCond();
SDL_mutex *Threads::_guiEventLock;// = SDL_CreateMutex();*/
Et voici, le contenu CPP
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
Threads::Threads()
{
    _gui = SDL_CreateThread(GUIThread, NULL);
    _guiEventLock = SDL_CreateMutex();
    _guiEventWait = SDL_CreateCond();
}
Threads::~Threads()
{
 
}
 
int GUIThread(void *nothing)
{
    SDL_Event ue;
    while(WaitEvent(&ue, Threads::GUIEventWait(), Threads::GUIEventLock()))
    {
        switch(ue.type)
        {
            case SDL_USEREVENT:
                printf("GUI THREAD: data1=%d\n", (int)ue.user.data1);
                break;
        }
    }
    return 0;
}
int WaitEvent(SDL_Event *ev, SDL_cond *c, SDL_mutex *m)
{
    int val = 0;
 
    SDL_LockMutex(m);
    while (0 == (val = SDL_PollEvent(ev)))
    {
        SDL_CondWait(c, m);
    }
    SDL_UnlockMutex(m);
    SDL_CondSignal(c);
 
 
    return val;
}
Voila maintenant je lance mon application....
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
 
ClientApp::ClientApp()
{
    // inf. loop
    running = true;
    // Pop the window
    _winst = new Window();
    // threads
    _thrds = new Threads();
}
Voici également le constructeur de Window
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
 
Window::Window()
{
    // initializing the window
	if(SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTTHREAD) == -1)
	{
		printf("Can't init SDL:  %s\n", SDL_GetError( ));
	}
 
	// When program exists
	atexit(SDL_Quit);
 
	// Window size, mode
	_w = SDL_SetVideoMode(WIN_DEFAULT_WIDTH, WIN_DEFAULT_HEIGHT, WIN_DEFAULT_BPP, SDL_HWSURFACE|SDL_DOUBLEBUF);
	if(_w == NULL)
	{
		printf("Can't set video mode: %s\n", SDL_GetError( ));
	}
 
	// Window title
	SDL_WM_SetCaption(WIN_DEFAULT_TITLE, WIN_DEFAULT_TITLE);
 
	_curscr = SCREEN_MENU;
 
    int w[2] = {WIN_DEFAULT_WIDTH,WIN_DEFAULT_WIDTH};
    int h[2] = {WIN_DEFAULT_HEIGHT,WIN_DEFAULT_HEIGHT};
	layers = SDLayer_CreateRGBLayeredDisplay(SDL_ANYFORMAT, SDLAYER_RECTS, 2, w, h, WIN_DEFAULT_BPP, 0, 0, 0, 0);
 
	SDL_SetAlpha(SDLayer_GetLayer(layers,SCREEN_MENU), SDL_SRCALPHA, 0);
	SDL_SetAlpha(SDLayer_GetLayer(layers,SCREEN_INGAME), SDL_SRCALPHA, 0);
 
}


Et... voici l'erreur !
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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
obj\Debug\ClientApp.o||In function `ClientApp':|
D:\C++\projects\Client\ClientApp.cpp|3|multiple definition of `Threads::_guiEventWait'|
obj\Debug\AppWindow.o:D:\C++\projects\Client\AppWindow.cpp|4|first defined here|
obj\Debug\ClientApp.o||In function `ClientApp':|
D:\C++\projects\Client\ClientApp.cpp|3|multiple definition of `Threads::_guiEventLock'|
obj\Debug\AppWindow.o:D:\C++\projects\Client\AppWindow.cpp|4|first defined here|
obj\Debug\Sprite.o||In function `Z10load_imageSs':|
D:\C++\projects\Client\Utilities.h|25|multiple definition of `Threads::_guiEventWait'|
obj\Debug\AppWindow.o:D:\C++\projects\Client\AppWindow.cpp|4|first defined here|
obj\Debug\Sprite.o||In function `Z10load_imageSs':|
D:\C++\projects\Client\Utilities.h|25|multiple definition of `Threads::_guiEventLock'|
obj\Debug\AppWindow.o:D:\C++\projects\Client\AppWindow.cpp|4|first defined here|
obj\Debug\Threads.o||In function `Threads':|
D:\C++\projects\Client\Threads.h|34|multiple definition of `Threads::_guiEventWait'|
obj\Debug\AppWindow.o:D:\C++\projects\Client\AppWindow.cpp|4|first defined here|
obj\Debug\Threads.o||In function `Threads':|
D:\C++\projects\Client\Threads.h|34|multiple definition of `Threads::_guiEventLock'|
obj\Debug\AppWindow.o:D:\C++\projects\Client\AppWindow.cpp|4|first defined here|
obj\Debug\main.o||In function `SDL_main':|
D:\C++\projects\Client\main.cpp|15|multiple definition of `Threads::_guiEventWait'|
obj\Debug\AppWindow.o:D:\C++\projects\Client\AppWindow.cpp|4|first defined here|
obj\Debug\main.o||In function `SDL_main':|
D:\C++\projects\Client\main.cpp|15|multiple definition of `Threads::_guiEventLock'|
obj\Debug\AppWindow.o:D:\C++\projects\Client\AppWindow.cpp|4|first defined here|
||=== Build finished: 16 errors, 3 warnings ===|
Quelqu'un saurais me dire ce qui cloche ? :o
Merci !