Visual Studio Code First C++ Project - c++

I'm investigating using VS Code for our current C++ project on Linux (using gcc to compile). Though I'm familiar with Visual Studio, Visual Studio Code is a different beast. I'm just trying to get a sample C++ app up in it, but even following this simple tutorial has proved fruitless.
It all falls apart early on. I have a one file program open. When I bring up the command palette, I don't have the "Tasks: Configure Task Runner" task. Since all the following steps depend on this one, I don't know how to proceed.
Was that command removed? Is there a better/more current step-by-step guide? I've heard great things about VS Code and really want to get it working.

Related

C++ Setup in Visual Studio Code fails to run

I just downloaded VSC in order to start learning C++. Previously I had just used Notepad++ for web design and Python IDE for Python, but I decided to move onto Visual Studio Code for a more sophisticated code editor.
However, when trying to run a basic program, I don't have the option to run in the first place. This picture is what's supposed to come up when you right-click on the text area (from multiple YouTube tutorials):
However, this is what comes up on my screen.
Additionally, there is no "run" button on the top-right of the screen like the tutorials show.
My folders regarding VSC in File Explorer are quite simple. I have a folder for my .cpp code, and MinGW as a compiler. My build is Windows 10.
Obviously, this depends from person to person, but is there any key way this situation can be resolved? Thank you in advance.

Build C++ Universal App from command line without MSBuild

In the same spirit as the question Can I download the Visual C++ Command Line Compiler without Visual Studio? I would like to see if it is easy to bundle the appropriate part of Visual Studio to build Universal App written in C++. Following the answer by #Alek to the aforementioned question, I managed to create an archive where I can basically unzip and use. But this is for traditional desktop (I would say, command-line) programs. I tried to do similar thing for Universal App and there are a couple of issues
The official way (i.e. what Visual Studio does under the hood) is to use MSBuild. Unfortunately, I do not know what are and how to get all of its dependencies. It seems to require significant configuration effort as well.
There is no documentation on how to build resources (e.g. generate C++ source and headers from XAML), how to generate the .appx. If possible, a Makefile template is very much appreciated.
The reason to ask for this is because Visual Studio failed me so many times. For instance, the November Update messed up my entire system; the SDK installer fail at 96% and rolled back. Previously, the upgrade to VS2015 (from 2013) also messed me up entirely. It seems that the only solution to these problems is complete uninstall. Having a portable archive where I can just unzip and restore my production environment back to health is something I would say extremely desirable.
Note: I do not care about the IDE. I only need the ability to build apps from source code on the command prompt.

building curl 7.46.0 on windows without cmd

curl being new to me, I am figuring out an easier way to compile it on Windows. I've managed to find a good documentation explaining in layman's terms all the steps, however this doc is based on curl-7.9.6.
It was simpler since curllib.dsw which is the Visual Studio Project file for curllib was found in folder curl-7.9.6\lib. So building it was resulting in libcurl.dll + libcurl.lib
Unfortunately this project file is no more in the latest version 7.46.0, and I would not like to mess around using other techniques I am not familiar with, compiler other than msvc (e.g MinGw), and if possible without resorting to cmd.
I have already done some researches online before posting this thread, but we never know maybe someone has written on this topic very simple documentation that everyone could understand and willing to share it publicly to get both the static library file and DLL (raised just above) or have found a way to get back the project file (.dsw) in the latest release which will a priori be straightforward to compile using Visual Studio 2013 (v120)
Best

How to make a c++ project run on a different PCs

I developed a small c++ program in Visual Studio 2012 on Windows7, 64bit (let's call it PC1). On that pc it runs fine!
Since I didn't have a versioning control system like SVN at hand, I copied ALL the project data (the exact folder structure, DLLs, source files, project files...) to a usb stick and moved it to another computer.
On that other engine there's Visual Studio 2010 on Windows7, 64bit (PC2).
So I just changed the platform toolset to v100 as described here.
I successfully compiled the project on PC2 (clean, build) and wanted to run the exe, but the command prompt stayed empty.
I then tried to debug and added a breakpoint at the very first line of main - which wasn't reached, the command prompt was still empty.
Ok, a usb stick is certainly not the most secure solution for data storage, so I gave it another try and moved it again - the problem remains.
Visual Studio's output on PC2 is the same as on PC1, so I couldn't find any anomalies there.
Yeah, there might be many error sources, so where can I start?
And how can I get a more verbose output for troubleshooting?
Or is this even a common phenomenon (perhaps due to different VS versions) and there's an simple way fix it?
This is not a full solution, but at least I'm a tiny step ahead:
In my last comment I wrote:
I took your advices into account and created a brand new project on PC2, VS2010. I exactly followed this guide: http://frozenhamster.wordpress.com/2011/02/11/lapack-on-windows-with-visual-studion-2010/
That didn't work either, so I removed I "out-commented" everything except for a single cout. Voila, that worked!
But as soon as I make use of the desired Armadillo (LAPACK and BLAS), the project compils but does not run.
What's going wrong here?
I don't get any compiler errors!

C++ error detection in Visual Studio 2005

Coming from a different development environment (Java, mostly) I'm trying to make analogies to habits I'm used to.
I'm working with a C++ project in Visual Studio 2005, the project takes ~10 minutes to compile after changes. It seems odd that if I make a small syntactical error, I need to wait a few good minutes to get a feedback on that from the compiler, when running the entire project build.
Eclipse gave me the habit that if I make some small change I will immediately get a compiler error with an underline showing the error. Seems reasonable enough that VS should be able to do this.
Is this something I can enable in VS or do I need an external plug-in for this?
The feature you are asking for will be available in Visual Studio 2010. Here is a detailed link of the feature details that will be available.
For now, as others have suggested, you can use Visual Assist which can help a little bit.
These are called Squiggles BTW.
You can try the following:
install a plugin like Visual Assist: it will notify you about most of the errors;
if you want to check yourself, use Ctrl-F7 to compile the file you are currently editing - in such case, you will not need to wait for all project to compile. If you are editing a header file, compile one of the .cpp files it is included in.
Yes, C++ is notorious for its build times. Visual Studio cannot perform on-the-fly syntax checking (in case of C++), but you can install Visual Assist to help with that:
(source: wholetomato.com)
10 minutes is quite a long time to wait, are you doing a full build every time? There are a lot of techniques you can use to speed this up, for example using precompiled headers. I try to organise my code so that I do all of my significant changes in the code file instead of the header, then just do a build of that one file (ctrl F7) to check for errors.
You have the "error list window" that will list your errors and warnings after compilation. If you double click on the error it will directly go to the problematic line of code in your source. It's in the menu Display, sub menu "Other windows".
Keep in mind that compiling C++ is a much more difficult task than compiling Java, which explains the increased time.
Visual Assist X is very cool but only detects typos.
It cannot be compiled "on the fly" which explain the feature you ask is not possible. If you have a multicore machine, you can enable parallel building.
Tools -> Options -> Projects and solutions -> Generate and Execute -> maximum number of parallel compilation.
Resharper for C# has it. But for c++, maybe visual assist x ?
Eclipse gave me the habit that if I make some small change I will immediately get a compiler error with an underline showing the error. Seems reasonable enough that VS should be able to do this.
Eclipse has implemented their own Java compiler, and run that in the background every time you type a word to be able to detect and underline errors. I don't know if I'd call that "reasonable". ;)
It's a lot of work to implement that feature, even in a simple language like Java.
In C++, where, as you've discovered, compiles may take minutes, it's harder still.
Visual Studio 2010 is going to implement this feature (again, using a separate compiler, which is much stripped down, and won't always provide correct results -- that's the compromise necessary to ensure that it's fast enough to compile on the fly).