When I try to run I receive this error:
main.cpp:1:18: fatal error: temp.h: No such file or directory #include "temp.h" compilation terminated.
Intellisense however, detects that this header is present.
Ctrl + left-clicking on #include "temp.h" in main.cpp successfully brings me to the file and the line of code has no squiggly lines underneath it.
I have two separate folders for .cpp files and header files and have configured the includePath in c_cpp_properties.json as such:
My workspace folder is temp and the line "${workspaceFolder}/**" should recursively check subfolders for headers. I added the absolute path to the header files with no success.
You have to compile the . cpp file first(using some cpp compiler like g++) which will give you an object file (like a. out ) that you can run as ./a.
Basically, the problem is with header files. I think you should try reinstalling mingw, adding it to system path again or try installing the extension in vscode.
Go to the menu Code > Preferences > Settings. In the User tab on the left panel, expand the Extensions section. Find and select Run Code Configuration. Find and check the box Run in Terminal.
1. We need to click on the extension button that displays a sidebar for downloading and installing the C/C++ extension in the visual studio code. In the sidebar, type C Extension. In this image, click on the Install button to install the C/C++ extension.
This question was a result of confusion between the tasks.json and the c_cpp_properties.json files. I was treating c_cpp_properties.json as though it was used for compilation.
c_cpp_properties.json is used with Intellisense and in no way deals with compilation.
tasks.json is used for compilation. If you're unfamiliar with tasks.json as I was you need to specify the include paths here as well.
In the args section of your tasks.json use "-I" to add an include path, followed by the path you wish to include.
For my problem that command looked like this:
"-I", "C:\Users\Dill\Desktop\temp\header"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With