Is a text-editor and a compiler all I need?

May 3, 2020 at 11:48am
Hello,
I'm very new to C++ and I would like to know if I have to download C++, just like I have to do it with Python. Or is a text-editor and a compiler all I need?

Also excuse my poor grammar, English isn't my native language.
Last edited on May 3, 2020 at 11:55am
May 3, 2020 at 11:59am
Or is a text-editor and a compiler all I need?


Yup. Although for "compiler" read "compiler and linker and some other handy bits", but generally they all come as a package.

What OS are you doing this on?
May 3, 2020 at 12:03pm
Windows 10 and Windows 7 sometimes. Also do I have to have the Microsoft C++ Redistributables installed on my PC to be able to program with C++?
May 3, 2020 at 12:09pm
Also do I have to have the Microsoft C++ Redistributables installed on my PC to be able to program with C++?


No; those are so that you can run, on your PC, programs written by other people on other PCs (probably using MS Visual C++ IDE of some kind), without them having to send you every last library and every last DLL needed.


You will need a compiler (and the other helpful bits as mentioned above, which generally all come packaged together). You will need to download a compiler; Windows 10 (and 7) doesn't come with one by default.

If you simply download, for example, MinGW ( https://sourceforge.net/projects/mingw-w64/ ) , opened the MinGW command line, wrote a text file main.cpp:

1
2
3
4
5
#include <iostream>
int main()
{
   std::cout << "Hello world";
}


you could then type:
g++ main.cpp


on the MinGW command line, and you'd have a program you can run that would output to screen.


But that's just one option among many.



Last edited on May 3, 2020 at 12:09pm
May 3, 2020 at 12:11pm
Alright! Thanks for the help.
May 3, 2020 at 12:27pm
You certainly can write code in an editor but have a look at some IDEs.
They make things much easier. Code formatting, Intellisense, syntax highlighting, integrated debugger are really useful.
Common modern IDEs on Windows are Visual Studio and Code::Blocks.
May 3, 2020 at 2:14pm
I recommend notepad++ if you want to do it without an IDE. It colors and has some features above most text editors. It colors keywords and constants (like numbers or text), has macros for repeated tasks, has rectangular copy and paste, and so on.

The compiler does not matter much. I use Cygwin to get unix command line tools like grep along with it; they install a version of g++.

Visual studio will install its own compiler along with the editor etc.


c++ does not work like python. Python, if you want a library, is a 2 second google and a 2 second install command and its done. C++ is closer to the machine, and each library is handled differently, you find it (or the source code to it) and install (or compile, following instruction) and tie it into your code at the command line with options sent to the compiler (or if you want to make a 'make' file for complex builds). I recommend you do not try to use any libraries for a while and focus on the core language. There are built in libraries, and you will have to use those, like <iostream> to print to the screen, you will see what I mean about those as you do your examples and get started. The ones that are a lot of work are third party tools like graphics/sound or making a zip file etc.
Last edited on May 3, 2020 at 2:15pm
May 3, 2020 at 2:45pm
So since C++ has built-in libraries I can just program using the 'core' language with a text-editor and a compiler or an IDE without having to download anything else. I hope I got this right.
Last edited on May 3, 2020 at 2:47pm
May 3, 2020 at 2:52pm
Yes.
May 3, 2020 at 4:21pm
If you are doing command-line compiling/linking consider looking at how to create and use make files. As your projects grow in size and number of source files a make file is a handy tool.

A make file is from a beginner's viewpoint a batch file to compile and link source files into an executable.

A web search link for tutorials on make files:
https://duckduckgo.com/?q=c%2B%2B+make+file+tutorial&t=ffsb&ia=web
May 4, 2020 at 6:47pm
So since C++ has built-in libraries I can just program using the 'core' language with a text-editor and a compiler or an IDE without having to download anything else. I hope I got this right.

yes. The core libraries only provide fairly low level tools: containers for data, simple algorithms like swap, tools to read keyboard and write to con,sole, date and time, and so on. The kinds of things it does not offer are interface to a mouse, sound, graphics, networking ... you will get a feel for it slowly; sometimes guessing what might be there (gcd??) and what might not be there (a binary search tree container??) will have you head scratching. There are reasons, but it takes time to see the method behind the madness.
May 4, 2020 at 8:10pm
I'm not sure I agree with the recommendations given in this thread.

I personally use a plain text editor and normally compile from the command line --

But I've been doing this for decades and know all the ins and outs of what for you is a very steep learning curve.

Since you are on Windows, just download Visual Studio 2019 and use the IDE to edit and compile everything. There is still a learning curve, but it is a nice one.

Make sure to select C++ as (one of) the languages that VS uses, and select the bundled Boost Libraries while you are at it.

It is easy enough to open a Command Window and execute your programs from the prompt as well.

Hope this helps.
Topic archived. No new replies allowed.