Saturday, July 20, 2024

SOLVED SDL h No such file or directory

Hi, everyone!

Environment: Debian 12, SDL2, vscode (extensions: C/C++ Language Support (MS), CMake Tools (MS) )

main.cpp

#include "SDL2/SDL.h"


c_cpp_properties.json

add: /usr/local/include
{
    "configurations": [
        {
            "name": "Linux",
            "includePath": [
                "/usr/include/SDL2",
                "/usr/local/include",
                "${workspaceFolder}/**"
            ],
            "defines": [],
            "compilerPath": "/usr/bin/gcc",
            "cStandard": "c17",
            "cppStandard": "c++17",
            "intelliSenseMode": "linux-gcc-x64",
            "compilerArgs": [
                "gcc main.cpp `pkg-config --cflags --libs sdl2`"
            ]
        }
    ],
    "version": 4
}


CMakeLists.txt
 

cmake_minimum_required(VERSION 3.5.0)
project(createwindow VERSION 0.1.0 LANGUAGES C CXX)

add_executable(createwindow src/main.cpp)

target_link_libraries(createwindow SDL2main SDL2 GL)
 

Hope this useful.

No comments:

Post a Comment