CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Jan 2009
    Location
    England
    Posts
    57

    [RESOLVED] No such file or directory with Hello World!

    I have just started to use vs code for a project but I have a simple issues that I am sure someone here will resolve in two minutes.

    I have a folder: c:\documents\projects\vmConsole. Inside vmConsole directory I have 3 directories called include, src and .vscode.

    When I separate my .h and ,cpp files I get No such file or directory in vs code. I am certain it's because I have not told g++ to look in include and src directories. I am aware of -I for g++ but I don't understand JSON files.

    I know the "-I ${fileDirname}./include", is wrong, can you advise as I have spent 2 days on this issue.

    launch.json file:

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




    I hope someone can advise.
    What the mind can conceive it can achieve.

  2. #2
    Join Date
    Nov 2018
    Posts
    114

    Re: No such file or directory with Hello World!

    Perhaps get rid of the spaces, dots and forward slashes.

    Code:
    "-I ${fileDirname}\\include",
    Although since you're using gcc, it probably also understands forward slashes, even though it's windows.

    Code:
    "-I ${fileDirname}/include",
    Forward slashes (if the tools accept them) are preferable, since back-slashes usually come with obscure quoting rules.

    Edit:
    If $fileDirname is pointing at your src, then you need
    Code:
    "-I ${fileDirname}\\..\\include",
    or
    Code:
    "-I ${fileDirname}/../include",
    If there's some $var for the project root (the directory containing both include and src), then that's a better thing to use. Less relative directory shenanigans.
    Last edited by salem_c; February 4th, 2024 at 07:52 AM.

  3. #3
    Join Date
    Jan 2009
    Location
    England
    Posts
    57

    Re: No such file or directory with Hello World!

    Thanks for the reply. None of those worked, but I'm still trying to get this to work. Just can't figure it out.
    What the mind can conceive it can achieve.

  4. #4
    Join Date
    Nov 2018
    Posts
    114

    Re: No such file or directory with Hello World!

    So can you paste your console output of a build attempt?

  5. #5
    Join Date
    Jan 2009
    Location
    England
    Posts
    57

    Re: No such file or directory with Hello World!

    I've fixed it. Deleted the text editor and installed a proper IDE that does a lot more!
    What the mind can conceive it can achieve.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured