Compiling and running your program

I have no idea what I’m doing honestly. Coming from Java, VS code 2019 is new to me. I’ve tried clicking the build button on the ide but when I want to run it, it says file not found. Then I looked at the folder on my desktop where I store my school work, and I don’t even see any .cpp or .h files, it’s a bunch of random extensions in a folder I unknowingly created in my school folder. What am I doing wrong? Is there something I should be doing? I know my code is proper and IDEs should compile for you? (I’ve even tried getting VS code non-ide and installing file runner by Jun Han to no avail).

Did you install the C++ extension for VS Code? And install a C/C++ compiler?

https://code.visualstudio.com/docs/languages/cpp
you may prefer to get visual studio (not CODE) version. It will have the compiler and all set up ready to go.

CODE is very stripped down; all I use it for is to interface to GIT.
I’ve installed all those extensions. Not sure if I did the compiler correctly with all the environment variable setting so I decided to use the IDE. I’m not sure what I’m doing wrong though because as I said it ends up just being a folder without the .cpp and .h files?
If you are on Windows you might want to consider using Visual Studio 2019 Community instead of Visual Studio Code, as jonnin suggests. Less hassles to set up and use.

https://visualstudio.microsoft.com/vs/community/

A decent tutorial for setting up VS 2019 is here:
https://www.learncpp.com/cpp-tutorial/installing-an-integrated-development-environment-ide/

Visual Studio 2019 requires a lot of hard-drive space, compared to Visual Studio Code. VS 2019 has a lot of developer tools integrated when you install the suite. Being able to edit, compile and run/debug from one IDE interface can be a good thing.

C/C++ is not default installed with either VS Code or Visual Studio, you need to perform a custom install.

Big PLUS is the installation process for VS 2019 will do all the environment variable settings for you.

I have VS Code and VS 2019 installed, and trying to compile and run code with VS Code can be a hassle at even the best of times.

As my fall-back secondary compiler/IDE I use Code::Blocks. Not as cranky as VS Code in my experience.
http://www.codeblocks.org/downloads

There are instructions for installing and using Code::Blocks at the Learn C++ tutorial as well.
Thank you for the detailed response. For the NON-IDE version, turns out I had the incorrect link for mingw. So I can finally code, but the IDE still will make a weird folder full of files EXCEPT for my .cpp/.exe
all IDE make a bunch of 'intermediate' files, not just an exe. All compilers make object files (usually about 1 per cpp file), but IDEs also put in all kinds of other stuff -- microsoft has a debug symbol database of some sort for example. But I can't say what happened to your cpp/h files. They should be nearby. The exe .. microsoft compiler likes to make a /debug and /release etc folder where it hides those, you can override it or just tolerate it. The exe file is only going to exist if the compile succeeded.
Don't worry about the files you don't understand. Its just the behind-the-scene stuff the IDE needs. One of them may open your project in the IDE, if you click on it.

my normal visual studio has
- top folder, with the .cpp files and .h files by default, and the ide file for the project (.sln, because we are chemists ... I thought solution was rock bottom until they invented the word app).
under that it has debug, release, where the respective exes from the builds are placed.
- cpp and h files can be anywhere, really, this is just where it makes them by default. You probably want a shared folder above all this where cpp files and h files that you reuse go.
Last edited on
Topic archived. No new replies allowed.