I'm trying to run a simple code that includes the "SDL.h" file, just to verify it works properly and it gives me no errors, but it's not like that. I'm using VS Code and MinGW compiler. Here is the code:
#include <iostream>
#include <SDL.h>
int main (int arcg, char* arcv[]) {
std::cout << "it works";
return 0;
}
I've installed all the SDL2 stuff and I put all the headers i need in a "sdl" folder, and this is my makefile:
all:
g++ -Iinclude -Iinclude/sdl -Iinclude/headers -Llib -o Main src/*.cpp -lmingw32 -lSDL2main -lSDL2 -lSDL2_image
The inconsistency is that while I'm writing the code the compiler doesn't give me errors (in other similar situations it does (the red underline), for example if I try to include a .h that doesn't exist) and when i digit "#include" it shows me all the files that i can include from the "sdl" folder, but when i run the program the error occurs:
main.cpp:2:10: fatal error: SDL.h: No such file or directory
2 | #include <SDL.h>
| ^~~~~~~
Someone help me
This is the directory structure pointed by tree:
.
├── Main.exe
├── MakeFile
├── SDL2.dll
├── SDL2_image.dll
├── include
│ ├── headers
│ └── sdl
│ ├── SDL.exe
│ ├── SDL.h
│ ├── SDL_assert.h
│ ├── SDL_atomic.h
│ ├── SDL_audio.h
│ ├── SDL_bits.h
│ ├── SDL_blendmode.h
│ ├── SDL_clipboard.h
│ ├── SDL_config.h
│ ├── SDL_cpuinfo.h
│ ├── SDL_egl.h
│ ├── SDL_endian.h
│ ├── SDL_error.h
│ ├── SDL_events.h
│ ├── SDL_filesystem.h
│ ├── SDL_gamecontroller.h
│ ├── SDL_gesture.h
│ ├── SDL_haptic.h
│ ├── SDL_hidapi.h
│ ├── SDL_hints.h
│ ├── SDL_image.h
│ ├── SDL_joystick.h
│ ├── SDL_keyboard.h
│ ├── SDL_keycode.h
│ ├── SDL_loadso.h
│ ├── SDL_locale.h
│ ├── SDL_log.h
│ ├── SDL_main.h
│ ├── SDL_messagebox.h
│ ├── SDL_metal.h
│ ├── SDL_misc.h
│ ├── SDL_mouse.h
│ ├── SDL_mutex.h
│ ├── SDL_name.h
│ ├── SDL_opengl.h
│ ├── SDL_opengl_glext.h
│ ├── SDL_opengles.h
│ ├── SDL_opengles2.h
│ ├── SDL_opengles2_gl2.h
│ ├── SDL_opengles2_gl2ext.h
│ ├── SDL_opengles2_gl2platform.h
│ ├── SDL_opengles2_khrplatform.h
│ ├── SDL_pixels.h
│ ├── SDL_platform.h
│ ├── SDL_power.h
│ ├── SDL_quit.h
│ ├── SDL_rect.h
│ ├── SDL_render.h
│ ├── SDL_revision.h
│ ├── SDL_rwops.h
│ ├── SDL_scancode.h
│ ├── SDL_sensor.h
│ ├── SDL_shape.h
│ ├── SDL_stdinc.h
│ ├── SDL_surface.h
│ ├── SDL_system.h
│ ├── SDL_syswm.h
│ ├── SDL_test.h
│ ├── SDL_test_assert.h
│ ├── SDL_test_common.h
│ ├── SDL_test_compare.h
│ ├── SDL_test_crc32.h
│ ├── SDL_test_font.h
│ ├── SDL_test_fuzzer.h
│ ├── SDL_test_harness.h
│ ├── SDL_test_images.h
│ ├── SDL_test_log.h
│ ├── SDL_test_md5.h
│ ├── SDL_test_memory.h
│ ├── SDL_test_random.h
│ ├── SDL_thread.h
│ ├── SDL_timer.h
│ ├── SDL_touch.h
│ ├── SDL_types.h
│ ├── SDL_version.h
│ ├── SDL_video.h
│ ├── SDL_vulkan.h
│ ├── begin_code.h
│ └── close_code.h
├── lib
│ ├── cmake
│ │ └── SDL2
│ │ ├── sdl2-config-version.cmake
│ │ └── sdl2-config.cmake
│ ├── libSDL2.a
│ ├── libSDL2.dll.a
│ ├── libSDL2.la
│ ├── libSDL2_image.a
│ ├── libSDL2_image.dll.a
│ ├── libSDL2_image.la
│ ├── libSDL2_test.a
│ ├── libSDL2_test.la
│ ├── libSDL2main.a
│ ├── libSDL2main.la
│ └── pkgconfig
│ ├── SDL2_image.pc
│ └── sdl2.pc
├── libjpeg-9.dll
├── libpng16-16.dll
├── libtiff-5.dll
├── libwebp-7.dll
├── src
│ └── main.cpp
└── zlib1.dll
8 directories, 103 files
And this is the new makefile:
all:
g++ -Iinclude -Iinclude/sdl -Iinclude/headers -Llib -o Main src/*.cpp -lmingw32 -lSDL2main -lSDL2 -lSDL2_image
tree .