FAQ: Compile & Execute - Compile and Execute

This community-built FAQ covers the “Compile and Execute” exercise from the lesson “Compile & Execute”.

Paths and Courses
This exercise can be found in the following Codecademy content:

Learn C++

FAQs on the exercise Compile and Execute

There are currently no frequently asked questions associated with this exercise – that’s where you come in! You can contribute to this section by offering your own questions, answers, or clarifications on this exercise. Ask or answer a question by clicking reply (reply) below.

If you’ve had an “aha” moment about the concepts, formatting, syntax, or anything else with this exercise, consider sharing those insights! Teaching others and answering their questions is one of the best ways to learn and stay sharp.

Join the Discussion. Help a fellow learner on their journey.

Ask or answer a question about this exercise by clicking reply (reply) below!

Agree with a comment or answer? Like (like) to up-vote the contribution!

Need broader help or resources? Head here.

Looking for motivation to keep learning? Join our wider discussions.

Learn more about how to use this guide.

Found a bug? Report it!

Have a question about your account or billing? Reach out to our customer support team!

None of the above? Find out where to ask other questions here!

Hi everyone,

I am very confused about the second exercise in C++ compile and execute part:

  1. Q1 asks us to compile hello.cpp

This is the code that I think should be right:

**int main() **

** std::cout << “Hello World!\n”;**
** $ g++ hello.cpp**


Here is the code that the system think is right(nothing has changed compare to the original code)

**int main() **

** std::cout << “Hello World!\n”;**
** $ g++ hello.cpp**

2. Q2 says to execute a.out
This my code, the system told me it was wrong:

**int main() **

** std::cout << “Hello World!\n”;**
** g++ hello.cpp** ** ./a.out**


Not sure about what the correct code is.

  1. When I click on “solution”, it gave me the original code.

hey devwhiz, it’s kind of hard to tell by the formatting of your message, but just to be clear are you typing the compile command in the terminal on the right side of your screen? In bash you should type g++ hello.cpp after the $ that is already there.

Hopefully this helps.


Whenever I attempt to compile the code using the following in the terminal
g++ hello.cpp
It does not create a new file called a.out like it is supposed too, this seems to lead on to later problems in the course. I have changed nothing to the default code in the “hello.cpp” file that would cause this issue, and I know that when typing g++ hello.cpp in the terminal that it needs to come after the dollar sign. I do not know if this is just an issue with me or an issue with codeacedmey, Please help me!


same thing happened to me, think its an issue in codecademy’s part. i sent in a bug report about it and hopefully it gets fixed soon

edit: tried entering ./a.out as the 2nd step instructed to, it allowed me to continue. so i think this should not be affecting the exercise?


the thing is just really broken

1 Like

I got the same problem too. I’m just posting to the plataform realize it’s really a bug.

Edit:I did the same thing. The file is not created but if you execute the command it works correctly.

i don’t undersatnd how to compile where i should write g++ ! what it means the terminal where i should write in !
please how did u do to compile

Please read this before you guys get mad !

Dear future user of C++ Codecademy the lesson isnt broken or bugged I will help you through this step by step!

First step, there is a terminal on the screen the tab is titled “bash” click on the $ sign that you see it will allow you to type in the terminal. Please type g++. Then press enter on your keyboard.

Next part of the lesson requires you to type ./a.out . Then press enter on your keyboard

That’s how you complete part 2 of the lesson . Keep learning friends =)


Hi everyone

I’m having some issues compiling my C++ ‘program’. I’ve followed the video tutorial (the visual studio one) on it step by step and used the exact same code and commands, but compiling fails with the following error message:

g++ : The term 'g++' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path was included, verify that the path is correct and try again.



I am working with c/c++ for Visual Studio Code, and trying to run my first program,

  int main () {
    std: :cout  <<"Hello World"!\n;

I got an errorg++ : The term ‘g++’ is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of
operable program. Check the spelling of
the name, or if a path was included, verify that the path is correct and try again.
At line:1 char:1

  • g++ hello.cpp
  •   + CategoryInfo          : ObjectNotFound: (g++:String) [], CommandNotFoundException
      + FullyQualifiedErrorId : CommandNotFoundException


install one

I’d try saying how but windows users tend to both have lots of expectations and also not know how to do things, and probably have to do some work-arounds because of windows and none of that makes it easy to help. But there are probably plenty of guides to google.

Otherwise I’d say install msys2 and then run $ pacman -S gcc and then you’d be done.

omg tyvm, never thought to click on the screen with the $ and type there.

There is small bug in this exercise. If the user enters any random command instead of the one mentioned, the exercise gets marked as green and the a.out file gets generated.

I am attaching a sample screenshot for reference.

this is exactly what I needed. I didn’t quite understand that it was asking me to enter the commands in the terminal and not the text editor… whoops!

Did you also put the " $" sign? i was sort of getting the problem at first until i read the hints

I understand how the bash scripting works here, but what terminal do you type this into when developing outside of the code academy compiler, the windows terminal?

Bash, Powershell, etc.



why is the file called a.out that the compiler creates? Is that just a g++ default name? is there somewhere in hello.cpp I’m not seeing where this is specified?

Hey Codecademy team, It would be great if you guys mentioned that g++ only works because we are using that specific compiler for the lesson.
People using visual studio automatically use msvc as a compiler for example
And most gaming consoles use clang to compile their c++ code.

1 Like