I've been wrestling with the .json settings in VS Code for some hours now and I'm pretty lost. All I want to do is link pdcurses to my project so I can start coding. I have intellisense set up, but the #include statement is throwing "curses.h: No such file or directory":
The .jsons:
settings.json:
{
"files.associations": {
"iostream": "cpp",
"vector": "cpp"
}
}
c_cpp_properties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\Visual Studio Code Projects\\pdcurs39/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\Mingw-w64\\mingw64\\bin\\g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64",
"forcedInclude": [],
"browse": {
"path": []
}
}
],
"version": 4
}
tasks.json:
{
"version": "2.0.0",
"tasks": [
{
"label": "build RL Test",
"type": "shell",
"command": "g++",
"args": ["-g", "-o", "RLTest", "RLTest.cpp"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
launch.json:
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/RLTest.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Mingw-w64\\mingw64\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Normal C++ packages are working fine. pdcurses is installed at C:\Visual Studio Code Projects\pdcurs39\ with a default mingw-w64 make in the wincon folder.
I think the issue is with not including the pdcurses.a file, but im not sure how to go about linking that...
Related
I get the error "fatal error: GLFW/glfw3.h: No such file or directory" when i try to compile this simple code:
#include <GLFW/glfw3.h>
int main()
{
}
I'm using Visual Studio Code 2019 with mingW g++ 8.1.0, the IDE is able to locate "GLFW/glfw3.h" he can even open it when doing a right click 'Go to Definition' but the compilator can't, how to resolve this error ?
EDIT: There are the JSON files used to compile the code:
launch.json:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/main.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\Mingw\\mingw32\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
c_cpp_propreties.json:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"/VulkanSDK/1.2.154.1/Include/**",
"/Projects/Libraries/glm/**",
"/Projects/Libraries/glfw-3.3.2/include/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:\\Mingw\\mingw32\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
tasks.json:
{
// See https://go.microsoft.com/fwlink/?LinkId=733558
// for the documentation about the tasks.json format
"version": "2.0.0",
"tasks": [
{
"label": "Build",
"type": "shell",
"command": "g++",
"args": [
"-o",
"main",
"-g",
"main.cpp"
],
"group": {"kind": "build", "isDefault": true}
}
]
}
As you can see in the call stack section, three threads are opened when there is no need for them? I think they are making the process slower. Can someone help me fix this please?
Thank you.
P.S.
Here is my c_cpp_properties.json file:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:\\MinGW\\lib\\gcc\\mingw32\\9.2.0\\include\\c++"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\MinGW\\bin\\g++.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
Here is my launch.json file:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"preLaunchTask": "C/C++: cpp.exe build active file",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
And here is my tasks.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": "C/C++: cpp.exe build active file",
"command": "C:\\MinGW\\bin\\g++.exe",
"args": [
"-g",
"${file}",
"-o",
"${fileDirname}\\${fileBasenameNoExtension}.exe"
],
"options": {
"cwd": "${workspaceFolder}"
},
"problemMatcher": [
"$gcc"
],
"group": "build"
}
]
}
I am trying to get vscode working for the first time. I really liked the debugging features and the cool UI but this multiple thread opening everytime is making things difficult. Any help is appreciated.
When attempting to compile a C++ program in VS Code I'm getting an error. The Executing task is: cl.exe /Zi /EHsc /Fe: 'c:\Users\Me\Documents\cpp\VRP\program.exe' 'c:\Users\Me\Documents\cpp\VRP\program.cc'
The error I get is:
program.cc
c:\Users\Me\Documents\cpp\VRP\program.cc(1): fatal error C1083: Cannot open include file: 'linear_solver/linear_solver.h': No such file or directory
The terminal process terminated with exit code: 1.
The first line in my program.cc file is: #include "linear_solver/linear_solver.h"
The Path "C:\Users\Me\Documents\CPP\or-tools_VisualStudio2019-64bit_v7.6.7691" is in my Environment Variables. The full path to where the header file "linear_solver.h" is located is "C:\Users\Me\Documents\cpp\or-tools_VisualStudio2019-64bit_v7.6.7691\include\ortools\linear_solver\". How do I direct the Microsoft C++ (MSVC) "cl.exe" compiler to locate that directory/file or modify the include statement to work in Visual Studio Code?
My c_cpp_properties.json file is:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**",
"C:/Users/Me/Documents/cpp/or-tools_VisualStudio2019-64bit_v7.6.7691/include/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"windowsSdkVersion": "10.0.18362.0",
"compilerPath": "C:/Program Files (x86)/Microsoft Visual Studio/2019/BuildTools/VC/Tools/MSVC/14.26.28801/bin/Hostx64/x64/cl.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "msvc-x64",
"compilerArgs": []
}
],
"version": 4
}
My launch.json is:
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${fileDirname}\\${fileBasenameNoExtension}.exe",
"args": [],
"stopAtEntry": false,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
],
"preLaunchTask": "cl.exe build active file"
}
]
}
My tasks.json is:
{
"version": "2.0.0",
"tasks": [
{
"type": "shell",
"label": "cl.exe build active file",
"command": "cl.exe",
"args": [
"/Zi",
"/EHsc",
"/Fe:",
"${fileDirname}\\${fileBasenameNoExtension}.exe",
"${file}"
],
"problemMatcher": ["$msCompile"],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
I'm first time learning c++ and have followed the guide on https://code.visualstudio.com/docs/cpp/config-mingw but I still cannot successfully compile and run a basic program. Here are my configurations, launch and tasks files.
The only issue I think could be occurring is that I have the code in my E: drive. Although I don't think this should be an issue. Any and all help appreciated.
Configurations:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"compilerPath": "C:\\MinGW\\bin\\gcc.exe",
"cStandard": "c11",
"cppStandard": "c++17",
"intelliSenseMode": "gcc-x64"
}
],
"version": 4
}
Launch:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/helloworld.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": true,
"MIMode": "gdb",
"miDebuggerPath": "C:\\MinGW\\bin\\gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}
Tasks:
{
"version": "2.0.0",
"tasks": [
{
"label": "build hello world",
"type": "shell",
"command": "gcc",
"args": [
"-g",
"-o",
"helloworld",
".vscode"
"helloworld.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
Output is:
> Executing task: gcc -g -o helloworld .vscode helloworld.cpp <
gcc.exe: error: helloworld.cpp: No such file or directory
The terminal process terminated with exit code: 1
Terminal will be reused by tasks, press any key to close it.
I'm setting up an IDE using Visual Studio Code for C++ and I have already downloaded and installed all the packages in MinGW Compiler and Git for using bash shell.
I followed this tutorial--> https://code.visualstudio.com/docs/cpp/config-mingw#_configure-debug-settings
However, there were several small details that differed in my case as i progressed through the tutorial for which I'm not aware of their impact(as I am a beginner):
c_cpp_properties.json was a little different in my case.
My code was this:
{
"configurations": [
{
"name": "Win32",
"includePath": [
"${workspaceFolder}/**"
],
"defines": [
"_DEBUG",
"UNICODE",
"_UNICODE"
],
"cStandard": "c11",
"intelliSenseMode": "gcc-x64",
"compilerPath": "C:\\MinGW\\bin\\g++.exe"
}
],
"version": 4
}
In tutorial under configure debug settings, it states: 'Note that the program name helloworld.exe matches what you specified in tasks.json'. On the contrary I had specified 'helloworld.cpp' instead of 'helloworld.exe' in tasks.json
Still I finished the tutorial, and while debugging as said in the tutorial, I got an error stating, helloworld.exe does not exist.
I'd be grateful if someone can provide some insights and ways to deal with these errors.
Please keep in mind that I'm a beginner while answering. Thank You.
Edit: The code for the file tasks.json that I'm using:
{
"version": "2.0.0",
"tasks": [
{
"label": "build hello world",
"type": "shell",
"command": "g++",
"args": [
"-g",
"-o",
"helloworld",
"helloworld.cpp"
],
"group": {
"kind": "build",
"isDefault": true
}
}
]
}
The code for the file launch.json that I'm using:
{
"version": "0.2.0",
"configurations": [
{
"name": "(gdb) Launch",
"type": "cppdbg",
"request": "launch",
"program": "${workspaceFolder}/helloworld.exe",
"args": [],
"stopAtEntry": true,
"cwd": "${workspaceFolder}",
"environment": [],
"externalConsole": false,
"MIMode": "gdb",
"miDebuggerPath": "C:/MinGW/bin/gdb.exe",
"setupCommands": [
{
"description": "Enable pretty-printing for gdb",
"text": "-enable-pretty-printing",
"ignoreFailures": true
}
]
}
]
}