Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Cannot Launch or Debug but can Compile [SOLVED]  (Read 1768 times)

0 Members and 1 Guest are viewing this topic.

s4game

  • Newbie
  • *
  • Posts: 8
    • View Profile
Cannot Launch or Debug but can Compile [SOLVED]
« on: June 09, 2024, 11:44:38 am »
Hi,

  • Windows 10
  • VS Code
  • C++ MinGW 13.1.0
  • SFML 2.6.1
  • Makefile


I can compile and execute the app all fine, but when I try to launch or debug the cpp file (by CTRL+F5), VS Code always gives me the same error:
Quote
SFML/Graphics.hpp: No such file or directory

I have tried changing the libs to their debug versions, but to no avail.


main.cpp:
Quote
#include <SFML/Graphics.hpp>

int main()
{
    //...

    return 0;
}



tasks.json:
Quote
{
    "tasks": [
        {
            "type": "cppbuild",
            "label": "C/C++: g++.exe build active file",
            "command": "D:\\Prgrams\\MinGW\\mingw64\\bin\\g++.exe",
            "args": [
                "-fdiagnostics-color=always",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}\\${fileBasenameNoExtension}.exe",
            ],
            "options": {
                "cwd": "${fileDirname}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            },
            "detail": "Task generated by Debugger."
        }
    ],
    "version": "2.0.0"
}


Makefile:
Quote
all: compile linkdebug

compile:
   g++ -c main.cpp -I"D:\Prgrams\SFML\SFML-2.6.1\include" -DSFML_STATIC

link:
   g++ main.o -o main -L"D:\Prgrams\SFML\SFML-2.6.1\lib" -lsfml-graphics-s -lsfml-window-s -lsfml-system-s -lopengl32 -lfreetype -lwinmm -lgdi32 -mwindows

linkdebug:
   g++ main.o -o main -L"D:\Prgrams\SFML\SFML-2.6.1\lib" -lsfml-graphics-s-d -lsfml-window-s-d -lsfml-system-s-d -lopengl32 -lfreetype -lwinmm -lgdi32 -mwindows

clean:
   rm -f main *.o



Thanks in advance
« Last Edit: June 16, 2024, 12:08:04 pm by s4game »

eXpl0it3r

  • SFML Team
  • Hero Member
  • *****
  • Posts: 11030
    • View Profile
    • development blog
    • Email
Re: Cannot Launch or Debug but can Compile
« Reply #1 on: June 15, 2024, 11:39:18 pm »
I don't really know/understand how VS Code's tasks.json and all the other configurations work, not even sure if VS Code will use the Makefile.
Personally, I can only recommend to use CMake and the CMake extension (SFML has a CMake template), which would not only be cross-platform, but also require less configuration magic (IMHO).

Have you checked the official guides on how to set things up?
Sounds like the path VS Code takes to start debugging is missing the include directory path.

https://code.visualstudio.com/docs/cpp/launch-json-reference
https://code.visualstudio.com/docs/cpp/cpp-debug
« Last Edit: June 15, 2024, 11:41:23 pm by eXpl0it3r »
Official FAQ: https://www.sfml-dev.org/faq.php
Official Discord Server: https://discord.gg/nr4X7Fh
——————————————————————
Dev Blog: https://duerrenberger.dev/blog/

s4game

  • Newbie
  • *
  • Posts: 8
    • View Profile
Re: Cannot Launch or Debug but can Compile
« Reply #2 on: June 16, 2024, 12:07:42 pm »
Oh, I have actually switched to using CMake template and since then everything was good. Thank you!