How to compile C++ code on Ubuntu.[1] First, let's start a new text file.
name@computer:~$ nano #include <iostream>
using namespace std;
int main()
{
cout << "hello world!\n"; return 0; }
I won't go into detail what the commands exactly stand for. You can read them in a tutorial that I linked to before.
Now and save your file as HelloWorld.cpp, and exit. In nano this is ctrl+x. Now we are going to do the compiling.(Finally, the very essence of this post.)
name@computer:~$ g++ HelloWorld.cpp -o HelloWorld Let's run it to see if it works.
name@computer:~$ ./HelloWorld
hello world!
name@computer:~$ [1] g++ package needs to be installed. See a previous post.
Geen opmerkingen:
Een reactie posten