Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Clang build an executrion file in vscode

I’ve been searching whole internet but I can’t find the solution for building my c++ project with clang compiler. I’m new to all this stuff and sorry for misunderstanding.
I have default tasks.json file:

{
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "clang++ build active file",
            "command": "C:/Program Files/LLVM/bin/clang++",
            "args": [
                "-std=c++17",
                "-stdlib=libc++",
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "${workspaceFolder}"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
  }

I can compile and this is what I’ve got compiled, 3 files:

enter image description here

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

I need to create executable somehow…
Thanks for help.

>Solution :

If you read the documentation (which is for MinGW but it’s exactly the same for Clang for Windows), you need to explicitly add the .exe suffix to your output file.

So your "executable" file is the one named main, without any suffix or "extension".

You need to change your tasks.json file to add the .exe suffix:

"${fileDirname}/${fileBasenameNoExtension}.exe"
# Note the suffix here -------------------^^^^
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading