FAQ: Compile & Execute - Compile and Execute (Naming Executable)


This community-built FAQ covers the “Compile and Execute (Naming Executable)” 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 (Naming Executable)

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!

when u type: ./hello is that read as “I’m want to navigate through the current directory in hello and compile it”?


You’re correct in that it’s a path relative to the current location leading to an executable file (assuming there’s a file there and that it is executable), but that file is not a compiler (unless of course you placed a compiler there). By all likelihood it is the result of already having compiled something.

To compile it you would instead use the path* to the compiler, and tell the compiler about where your source file is

*but the compiler is probably in your $PATH so only the base name needs to be used ie g++ instead of /usr/bin/g++


I realize these are just the beginning lessons, but I am curious. How do we clear the terminal screen before “Hello World!” prints there?

By typing clear in the terminal?

Btw, if it helps anyone else, after only working with interpreting languages until now, this article really helped me out.

I thought that when I put the command: g++ hello.cpp -o hello
I could switch to any name I want, per exemple: g++ hello.cpp -o byebye
Then the file will be renamed as byebye

But that’s not possible. Why?

Because I understand that we can change the name of output executable file to specific name that we chose, but when I tried to put a different name a mistake appears

nevermind, I understand why now :sweat_smile:

(post deleted by author)

Whenever I try to execute the file using ./hello it keeps saying segmentation fault, any ideas why?