Reputation: 23
I am struggling with compiling my program using SDL and SDL_image libraries with MinGW. When I try to build my program I always get these errors. I've already tried two methods: manually install (this one showed me same errors but I was able to compile my program using MakeFile but the problem is I'm not getting any errors messages even if I have them), vcpkg tool (I did everything as in the tutorial but this time program does not build at all and shows same thing).
Addition to the first method: In my project I have 3 files which are actually parts of program written by me (main.cpp,RenderWindow.hpp header file,renderwindow.cpp source file that desribes header). And as I've already mentioned I have a MakeFile which contains this:
output: main.o renderwindow.o
g++ -Isrc/include -Lsrc/lib main.o renderwindow.o -o output -lmingw32 -lSDL2main -lSDL2 -lSDL2_image
main.o: main.cpp
g++ -Isrc/include -Lsrc/lib -c main.cpp -lmingw32 -lSDL2main -lSDL2 -lSDL2_image
renderwindow.o: renderwindow.cpp
g++ -Isrc/include -Lsrc/lib -c renderwindow.cpp -lmingw32 -lSDL2main -lSDL2 -lSDL2_image
clean:
rm *.o output
Also I have two dll files (SDL2.dll,SDL2_image.dll) in my workspace. Everything is building but if I have errors I don't even know that because nothing shows up in terminal and I have to manually look for them and it's not ok.
Addition to the second method: I decided to install SDL and SDL_image using vcpkg. I've installed libraries successfully with vcpkg, I have a CMakeLists.txt that looks like this:
type herecmake_minimum_required(VERSION 3.0.0)
project(game VERSION 0.1.0)
INCLUDE_DIRECTORIES(
D:/D/vcpkg/vcpkg/installed/x64-windows/include
)
LINK_DIRECTORIES(
D:/D/vcpkg/vcpkg/installed/x64-windows/lib,
D:/D/vcpkg/vcpkg/installed/x64-windows/lib/manual-link
)
add_executable(game main.cpp)
TARGET_LINK_LIBRARIES(game
SDL2 SDL2_image
)
I have automatically generated build folder with all Cmake things as well but still getting "SDL.h: No such file or directory".
I searched the internet for a solution to this problem but nothing helped and I assume from what I've already found that this problem is related to linker stuff.
P.S. I have the latest MinGW,SDL/SDL_image and VS Code versions.
Upvotes: 0
Views: 178