0

I was tryna transition from seperate IDEs to a single one where I can use with everything (Python, C++ and Web). I chose VSCode, since it had all of the necessary stuff in it. I finished setting up Conda and Python, but when I got to C++ I had a problem compiling my task.json file. The error was that wchar.h couldn't be found. It compiles and works fine on XCode, and CLion, but the Clang just doesn't work on VSCode. Any ideas on how to fix this?

Thanks

HJ

Here is the error code for reference

In file included from /Users/kimh2/Desktop/Coding Stuff/C++/HelloWorld/main.cpp:1:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iostream:38:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/ios:215:
In file included from /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/iosfwd:96:
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/../include/c++/v1/wchar.h:119:15: fatal error: 
      'wchar.h' file not found
#include_next <wchar.h>
              ^~~~~~~~~
1 error generated.
The terminal process terminated with exit code: 1

The task.json file:

{
    // See https://go.microsoft.com/fwlink/?LinkId=733558 
    // for the documentation about the tasks.json format
    "version": "2.0.0",
    "tasks": [
        {
            "type": "shell",
            "label": "clang++ build active file",
            "command": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        },
        {
            "type": "shell",
            "label": "clang++ build active file",
            "command": "/usr/bin/clang++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        },
        {
            "type": "shell",
            "label": "clang++ build active file",
            "command": "/usr/bin/clang++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": "build"
        },
        {
            "type": "shell",
            "label": "clang++ build active file",
            "command": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang++",
            "args": [
                "-g",
                "${file}",
                "-o",
                "${fileDirname}/${fileBasenameNoExtension}"
            ],
            "options": {
                "cwd": "/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin"
            },
            "problemMatcher": [
                "$gcc"
            ],
            "group": {
                "kind": "build",
                "isDefault": true
            }
        }
    ]
}
Hyungjun
  • 65
  • 7
  • 1
    You probably need to show your json settings (tasks.json, launch.json and c_cpp_properties.json) for your project in `Visual Studio Code` – drescherjm Mar 30 '20 at 13:04
  • Hey, I added the JSON file to the post. – Hyungjun Mar 30 '20 at 13:06
  • @drescherjm I was only up to the compilation of the file, so the launch and c_cpp_properties.json can't be found within the project – Hyungjun Mar 30 '20 at 13:12
  • 2
    You really should consider using CMake instead of trying configure everything in your tasks.json. From what it looks like you forgot to tell your compiler about your include directories. – Eric Mar 30 '20 at 13:13
  • @Eric I'm not really that experienced in CMake etc, I have only used XCode and CLion to handle all the compiling shenanigans (retrospectively isn't a good thing). Is there a way in VSCode to have the same functionality as the compiler/builders on those apps? If not, is CMake easy to learn/understand. – Hyungjun Mar 30 '20 at 13:21
  • Does this answer your question? ['wchar.h' file not found](https://stackoverflow.com/questions/46342411/wchar-h-file-not-found) – Botje Mar 30 '20 at 15:04
  • @Hyungjun It is easier than what you are trying to do. Configuring how to build your project is what CMake is made for. It would be kind of pointless if it was easier to invoke your compiler by hand. – Eric Mar 30 '20 at 15:59
  • Oh okay, I will look into that. I've just installed the code runner extension for the time being. Hopefully your solution works better – Hyungjun Mar 31 '20 at 00:31

0 Answers0