SDL2 Error

 I am in the process of learning C++ programming using SDL, but I can't even get it to compile. I have the includes and lib paths added to CLion and it recognizes them, but it keeps throwing errors while linking.

ERRORS:

C:\Users\TreyG\AppData\Local\JetBrains\Toolbox\apps\CLion\ch-0\171.4073.41\bin\cmake\bin\cmake.exe --build "C:\Users\TreyG\CLionProjects\Test Project\cmake-build-release" --target Test_Project -- -j 8
Scanning dependencies of target Test_Project
[ 50%] Building CXX object CMakeFiles/Test_Project.dir/main.cpp.obj
[100%] Linking CXX executable Test_Project.exe
CMakeFiles\Test_Project.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x1c): undefined reference to `SDL_Init'
CMakeFiles\Test_Project.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x59): undefined reference to `SDL_CreateWindow'
CMakeFiles\Test_Project.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x6d): undefined reference to `SDL_Delay'
CMakeFiles\Test_Project.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x72): undefined reference to `SDL_Quit'
CMakeFiles\Test_Project.dir/objects.a(main.cpp.obj):main.cpp:(.text+0x101): undefined reference to `SDL_GetError'
c:/code/mingw/bin/../lib/gcc/mingw32/5.3.0/../../../libmingw32.a(main.o):(.text.startup+0xa0): undefined reference to `WinMain@16CMakeFiles\Test_Project.dir\build.make:96: recipe for target 'Test_Project.exe' failed
'
collect2.exe: error: ld returned 1 exit status
CMakeFiles\Makefile2:66: recipe for target 'CMakeFiles/Test_Project.dir/all' failed
mingw32-make.exe[3]: *** [Test_Project.exe] Error 1
mingw32-make.exe[2]: *** [CMakeFiles/Test_Project.dir/all] Error 2
CMakeFiles\Makefile2:78: recipe for target 'CMakeFiles/Test_Project.dir/rule' failed
mingw32-make.exe[1]: *** [CMakeFiles/Test_Project.dir/rule] Error 2
mingw32-make.exe: *** [Test_Project] Error 2
Makefile:117: recipe for target 'Test_Project' failed

 

Please help, I don't know what is wrong.

This is Windows 10

CLion 17.1.1

MinGW Compiler

0
2 comments
Avatar
Permanently deleted user

I'm seeing the same problem on Linux. I can build fine with make but CMake isn't putting something together correctly.

0

Please take a look at this instruction. It's for Windows, but you can do similar actions on Linux.

0

Please sign in to leave a comment.