Bonjour,
C'est la promière fois que je travaille avec la SDL ... et je n'ai pas encore bien compris le fonctionnement de Cmake ^^.
Voici mon erreur :
CMakeList.txt :
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 "C:\Program Files (x86)\JetBrains\CLion 1.2.5\bin\cmake\bin\cmake.exe" --build C:\Users\loucass003\.CLion12\system\cmake\generated\7eed0371\7eed0371\Debug --target Game -- -j 4 -- Configuring done -- Generating done -- Build files have been written to: C:/Users/loucass003/.CLion12/system/cmake/generated/7eed0371/7eed0371/Debug -- Configuring done -- Generating done -- Build files have been written to: C:/Users/loucass003/.CLion12/system/cmake/generated/7eed0371/7eed0371/Debug Scanning dependencies of target Game [ 50%] Building CXX object CMakeFiles/Game.dir/main.cpp.obj [100%] Linking CXX executable Game.exe c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libmingw32.a(main.o):(.text.startup+0xa7): undefined reference to `WinMain@16' CMakeFiles\Game.dir/objects.a(main.cpp.obj): In function `SDL_main': C:/Users/loucass003/Documents/Prog/Code/C/Starmade/main.cpp:8: undefined reference to `SDL_Init' C:/Users/loucass003/Documents/Prog/Code/C/Starmade/main.cpp:18: undefined reference to `SDL_CreateWindow' C:/Users/loucass003/Documents/Prog/Code/C/Starmade/main.cpp:23: undefined reference to `SDL_GetError' C:/Users/loucass003/Documents/Prog/Code/C/Starmade/main.cpp:29: undefined reference to `SDL_Delay' C:/Users/loucass003/Documents/Prog/Code/C/Starmade/main.cpp:32: undefined reference to `SDL_DestroyWindow' C:/Users/loucass003/Documents/Prog/Code/C/Starmade/main.cpp:35: undefined reference to `SDL_Quit' collect2.exe: error: ld returned 1 exit status CMakeFiles\Game.dir\build.make:95: recipe for target 'Game.exe' failed mingw32-make.exe[3]: *** [Game.exe] Error 1 mingw32-make.exe[2]: *** [CMakeFiles/Game.dir/all] Error 2 CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/Game.dir/all' failed CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/Game.dir/rule' failed Makefile:117: recipe for target 'Game' failed mingw32-make.exe[1]: *** [CMakeFiles/Game.dir/rule] Error 2 mingw32-make.exe: *** [Game] Error 2
main.cpp :
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8 cmake_minimum_required(VERSION 3.3) project(Game) set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11 -lmingw32 -lSDL2main -lSDL2") set(SOURCE_FILES main.cpp) add_executable(Game ${SOURCE_FILES} )
Merci pour d'avance pour votre aide.
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 #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; }
Partager