Unable to debug c++ code in Visual Studio Code - c++

I've just installed Visual Studio Code v1.7.1 to write my c++ code in for my degree. My programming level is pretty basic, but I like what I've seen of VS Code so far, save for the fact that I've no idea how to debug or build my code.
I've looked at a few questions on the topic, such as: How do I set up VSCode to compile C++ code?
and have tried implementing some of these into the tasks.json file, including the make command and the g++ command, but when I try and execute it I get the error:
'make' is not recognized as an internal or external command,
operable program or batch file.
or something similar. When I try running the debugger, it tells me to set up the launch.json file, so I entered the path of my file where it says 'program' as the instructions imply, I get the error
Unknown Error: 0x800700c1
I'm just looking for the simplest option that will allow me to write and debug code in vs code, in a manner similar to using the full version of visual studio, but without the heavy project filing system or the 10 minute loading times. Any help would be greatly appreciated.

What I deduce from your question and the comments is that you have no actual C++ compiler/buildchain installed. There are multiple compilers available (like minGW, GCC).
However, what Microsoft recommends is the following:
Installing C/C++ build tools
To obtain your set of C/C++ compilers on Windows you can grab the Visual C++ build tools SKU. By default these tools are installed at ‘C:\Program Files (x86)\Microsoft Visual C++ Build Tools’.
I have not tested, nor ever worked with the Visual C++ compiler, but it's probably the easiest way to get started right away.

Related

Eclipse doesn't recognize printf with visual studio build tools 2022 headers

I'm trying to setup local Windows eclipse for remote Linux development. I have encountered problem with eclipse not recognizing simple 'printf()' statement from <stdio.h>. I didn't find any helpful resources ATM to solve this problem, so wondering if you could help me with this.
Header files used from: Visual Studio Build Tools 2022, specifically I'm including this folder for stdio.h file: 'C:\Program Files (x86)\Windows Kits\10\Include\10.0.19041\ucrt'
GCC C++ Compiler as: "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\Llvm\bin\clang.exe"
Eclipse IDE still highlights this as 'Function cannot be resolved':
I am not sure, but looks like 'printf' function is available at 'stdio.h':
Update:
Eclipse version used:
Using command line build is working as expected:
Program runs as expected:
So the questions are:
What needs to be done so eclipse would recognize 'printf'? e.g. Change MS Win Kits for another compiler header files? Or my eclipse configs are wrong?
If it is not possible for eclipse to recognize 'printf', is there an option to ignore all warnings on 'printf' (not highlight them)?
Let me know would you need anymore details from my side.
After some investigation I think 'clang' is not compatible with eclipse & it's way easier to install & use 'cygwin' for such purposes.
Some references:
https://www.eclipse.org/forums/index.php/t/1092409/
https://www.eclipse.org/forums/index.php/t/1102938/

How can I solve the directory problem of cplex in eclipse?

[enter image description here][1]I'm developing a c++ code on eclipse and i need cplex.
#include "ilcplex/ilocplex.h".
I have made this passages:
- project\properties\C/C++ built\Settings\GCC C++ compiler\Includes:
"C:\Program Files\IBM\ILOG\CPLEX_Studio126\cplex\include"
-project\properties\C/C++ built\Settings\MinGW C++ Linker\libraries:
"C:\Program Files\IBM\ILOG\CPLEX_Studio126\cplex\include\ilcplex"
and the library seems to be ok, since if i use f3 it works.
Despite this, it continues to give me this message:
fatal error: ilcplex/ilocplex.h no such file or directory.
I have tried to follow the instructions of the other similar posts, but nothing changed.
Can you please help me?
Even if you fix the error you are getting now, using CPLEX with gcc on Windows is not something that is supported, and it's likely you'll just run into another error. If you look at the detailed system requirements for CPLEX on Windows, you will see that Visual Studio 2015 or Visual Studio 2017 is required. You should take a look at the c_cpp.html file that gets installed with CPLEX for instructions on how to set up the Visual Studio environment when working with C/C++ projects.

How to include the ncurses.h library in C++ Visual Studio Linux Project when targeting Ubuntu on Windows?

I am trying to create a C++ console based program that will utilize the ncurses.h library. I am using Visual Studio 2017 targeting the WSL subsystem (Ubuntu).
Within ubuntu, running on my WSL, I have installed the ncurses libraries successfully.
I have created a new Project in VS. After unsuccessfully being able to get the #include to work correctly, I followed instructions on Stack to and added 'ncurses' in the Library Dependencies line under Linker / Input in the VS project properties. This enabled the application to compile the first time, and I was able to see in the Console Output that the library file was found and linked. However, VS still gives squiggly lines (errors) under all of the function names associated with the ncurses library. Also, the code does not work as expected, as the terminal appears to freeze. After running the code 2x, it appears now that the code will not build at all and I receive a strange error message that says the "program to debug does not exist on the remote system"
Can anyone please help? I've been using Visual Studio as my IDE with the WSL for school and would like to continue doing so. Future projects will be dependent on the ncurses library.
thank you for your help

Visual Studio 2017 wont show c++ template/extansion

I am trying to use Microsoft visual studio IDE to run my c++ code, however, when I go to create a project, I do not see the option for a c++ project. I tried reinstalling the program to see if I could somehow install the package/extension however it just won't seem to come up.
The only templates that appear are in c# or f#.
If someone could please lead me into the right direction so that I can fix this, it would be great. Thank you.
I don't see any mention of C++ in the release notes.
According to this post on MSDN, there is no C++ support in the Mac version of Visual Studio. It contains links to instructions for using Visual Studio Code, as well as the option to install a VM running Windows.
Apparently Visual Studio Code supports C++ projects, since it can execute external tools. The Microsoft Visual C++ build tools are free for Windows, but I don't think there is a version for the Mac, so some other external compiler is necessary.

Visual Studio 2013 OpenCL header file not found error [duplicate]

I am currently using Intel's OpenCL SDK platform for heterogeneous parallel programming (OpenCL). I am using Visual Studio 2010 Ultimate for this. My system doesn't have any GPU in it. I have worked on CUDA SDK platform for opencl programming. This the first time I am using Intel's OpenCL SDK for opencl programming.
I have tried some basic platform, device, context identifying/creating/defining codes from 'OpenCL in Action' book. They all worked fine. So we can consider that visual studio is properly configured.
Now, I am trying to build a 'Hello World' program in visual studio which gives me following error:
Error MSB3721: The command ""C:\Program Files (x86)\Intel\OpenCL SDK\3.0\bin\x86\ioc32.exe" -cmd=build -input="E:\Menu\Google\programs\1code\feb\10feb2014\OpenCL\OpenCL\hello.cl" -output="Debug\hello.out" -VS -device=CPU -simd=default -bo=" "" exited with code -1073741511. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\BuildCustomizations\IntelOpenCL.targetS
Now my questions are:
What is the significance of this 'Error MSB3721'?
Is this a programming related error or something is wrong with the 'OpenCL + Visual Studio' configuration?
I am trying to be as specific as possible in this question. Let me know if I have not providing enough information and help me out. I really appreciate your concern.
I don't know what it is, but i had the same problem when there was some *.cl file in my project. Just remove it from project (not from disk)! Anyway you will be able to read your source from this *.cl file, but when this file presents in project it causes en error. I don't know why.
I think the cause of the error is Intel codebuilder configuration or infinite loop in .cl file.
Please check if your error can be resolved by below two changes.
If you build your project as the Codebuilder project (e.g. Empty Opencl Project for Windows),
1-1. Right click your project and select properties
1-2. Select OpenCL Code Builder tab
1-3. If your device is configured as Intel(R) CPU (-device=CPU), then change it to your GPU device (e.g. Intel(R) Graphics (-device=GPU) in my case)
If you face the same error, then check if your .cl file contains the infinite loop such as while(1) or for(;;)
I've got the same error. Changing solution platform from x32 to x64 fixed it (I've got x64 machine).