C++ Setup For VS Code [duplicate] - c++

This question already has answers here:
How do I set up Visual Studio Code to compile C++ code?
(14 answers)
Closed 10 months ago.
So my teacher is wants the class to install C++, and I don't know how to do it. Please help me set it up in Visual Studio Code because it's the IDE I'm most familiar with. Please explain it in the simplest way possible.

If you are going to edit and execute on Windows, you have to install either Visual Studio regardless or g++ under MinGW. These instructions are very detailed:
https://code.visualstudio.com/docs/languages/cpp
To configure VSCode with MS compiler:
https://code.visualstudio.com/docs/cpp/config-msvc
To configure VSCode with gcc on Windows:
https://code.visualstudio.com/docs/cpp/config-mingw
Another alternative that I recommend is to use Windows WSL which is like a Linux inside Windows.
https://code.visualstudio.com/docs/cpp/config-wsl
Then install the C++ extensions for VSCode.
Then I recommend you install cmake for Windows. Although the tutorials will teach you how to build a single file, you will need more for large projects.
https://cmake.org/install/
Create a CMakeLists.txt and then use the cmake-gui to create the Visual Studio project files. All this is outside Visual Studio Code.
To build from inside VSCode I found it particularly cumbersome. I'd rather Alt-Tab and build the project manually by either calling 'make' or building inside Visual Studio. But it's your preference.
But if you are editing on Windows and running on Windows, I'd strongly suggest to run inside Visual Studio itself. Not only you will have way more support for your questions but also the Visual Studio debugger is arguably the best in the market.

Related

how to setup Visual Studio Code for c++ for windows? [duplicate]

This question already has answers here:
How do I set up Visual Studio Code to compile C++ code?
(14 answers)
Closed 3 months ago.
So my teacher is wants the class to install C++, and I don't know how to do it. Please help me set it up in Visual Studio Code because it's the IDE I'm most familiar with. Please explain it in the simplest way possible.
I tried installing vscode and c++ extension but library files are missing
If you are going to edit and execute on Windows, you have to install either Visual Studio regardless or g++ under MinGW. These instructions are very detailed:
https://code.visualstudio.com/docs/languages/cpp
To configure VSCode with MS compiler:
https://code.visualstudio.com/docs/cpp/config-msvc
To configure VSCode with gcc on Windows:
https://code.visualstudio.com/docs/cpp/config-mingw
Another alternative that I recommend is to use Windows WSL which is like a Linux inside Windows.
https://code.visualstudio.com/docs/cpp/config-wsl
Then install the C++ extensions for VSCode.
Then I recommend you install cmake for Windows. Although the tutorials will teach you how to build a single file, you will need more for large projects.
https://cmake.org/install/
Create a CMakeLists.txt and then use the cmake-gui to create the Visual Studio project files. All this is outside Visual Studio Code.
To build from inside VSCode I found it particularly cumbersome. I'd rather Alt-Tab and build the project manually by either calling 'make' or building inside Visual Studio. But it's your preference.
But if you are editing on Windows and running on Windows, I'd strongly suggest to run inside Visual Studio itself. Not only you will have way more support for your questions but also the Visual Studio debugger is arguably the best in the market.

How to distribute a console application? [duplicate]

This question already has answers here:
Problems with running EXE file built with Visual Studio on another computer
(6 answers)
Closed 2 years ago.
I am new to C++ and recently made a Tic-Tac-Toe game, which is a console application (no graphics). I have built my project in Release mode in Visual Studio 2019. I want this application to be transferred from one computer to another. I have zipped the Release folder of Visual Studio and tried to transfer it into another PC. When I ran it on another PC it failed to work?
I am new to programming, please help.
You don’t mention the exact error, but a first order possibility is a missing dependency.
Odds are you are missing the Visual Studio C++ runtime on the target machine (the one you are coping to). Windows does not install them by default, but Visual Studio does install them.
To download the runtime, go to https://visualstudio.microsoft.com/downloads/ then navigate to “Other tools and frameworks” then “Microsoft Visual C++ Redistributable for Visual Studio“. Select the version that matches your build and download and install it. You can copy the runtime dlls over from your PC, but installing them is generally easier and better for maintenance. If you are using an older version of Visual Studio, the download is normally available, but you’ll have to search for it.
Failing that, you may have another dependency missing. You should look to tools such as Dependency Walker, still available here https://www.dependencywalker.com/.
It must be run on pc's which OS you built on if it doesn't have additional libraries (Not Standart). if you have additional libraries, Add .dll files into release folder.
If you need help on customizing Console, I'll glad to help you on this.

Visual c++ problem in compiling native windows 10 application [duplicate]

This question already has answers here:
MSVCP140D.dll missing, is there a way around? [closed]
(2 answers)
Closed 3 years ago.
I'm coding a native C++ application in Vs 2019 that sould be able to run on a freshly configured windows 10 machine.
The problem is that when i run my .exe app on this machine i get missing dlls error such as MSVCP140D.DLL, VCRUNTIME140D.dll etc.
I tried to install the vcredist from MSDN on the guest machine and i also tried changing the "runtime library" from the "code generation" module in the project config.
I also followed some other tutorials that i've read on this platform but i can't find nothing that really works.
I even tried to place the missing dlls in the same directory of the .exe file to register them manually, actually it does not work, but this app i'm developing should be redistributable so the user should have just to execute it.
If i try to compile my program with another compiler such as MinGw it works but i wanted to use the vc++ default compiler if possible.
Is there a way to solve this issue?
Thanks!
Maybe you used MSVCP140.DLL, wihtout the D. the D stands for DEBUG and I don't know if the Debug version version comes with the visual studio redistributable. If you compile in visual studio try to build the Release version, this should work with the DLL´s from the redistributable

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.

Compiling a C++ project in Visual Studio 2015 created in Linux containing make file

I have some C++ projects/programs which are created in Linux and containing make file as well.
I am using window 7 and visual studio 2015. Today I just installed Ubuntu Linux in virtual box BUT do not really know how to start with and run these programs.
What is the easiest way to run theses projects?
I am very new in C++ programming so a detailed answer is needed.
If you want to work in Visual Studio on Windows a good choice would be Visual C++ for Linux Development (VCLinux) : see tutorial here
The tutorial creates a Visual Studio (VS) project that builds with MSBuild (VS's internal build system). However you can also create a makefile project that will build with make. MSBuild is easier to work with if you know VS or have an existing VS project, make is more flexible and might be the best choice given an existing makefile. You should try some simple examples and decide which works for you.