I’m trying to set up an OpenGL project using SDL2 in Visual Studio Code on macOS, but I’m running into two issues:
SDL2 Libraries Not Found: Visual Studio Code can’t find the SDL2 libraries even though I’ve installed SDL2. How can I configure it to locate the SDL2 files? It is showing up as red in the library import, and I used to get this error, which I actually already fixed:
Error: `dyld[3406]: Library not loaded: @rpath/SDL2.framework/Versions/A/SDL2 Referenced from: ... Reason: no LC_RPATH's found`MI Error with LLDB: When I try to debug the project, LLDB gives a machine interface driver error. What’s the correct configuration to fix this?
Error:
Starting: "/usr/bin/lldb" --interpreter=mi error: unknown option: --interpreter=mi Use 'lldb --help' for a complete list of options. "/usr/bin/lldb" exited with code 1 (0x1).
Here are my configuration files:
tasks.json
{
"version": "2.0.0",
"tasks": [
{
"type": "cppbuild",
"label": "C/C++: clang++ build active file",
"command": "/usr/bin/clang++",
"args": [
"-fcolor-diagnostics",
"-fansi-escape-codes",
"-g",
"${file}",
"-o",
"${fileDirname}/${fileBasenameNoExtension}",
"-F/Library/Frameworks",
"-framework", "SDL2",
"-framework", "OpenGL",
"-I/Library/Frameworks/SDL2.framework/Headers",
"-Wl,-rpath,/Library/Frameworks"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug C++ File",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "lldb",
"preLaunchTask": "C/C++: clang++ build active file",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"miDebuggerPath": "/usr/bin/lldb"
}
]
}
How can I ensure that SDL2 libraries are correctly linked and found by Visual Studio Code? And what configuration changes might be needed to resolve the LLDB debugging issue?