C++ Binaries In Linux: A How-To

I have been trying to learn C++ for quite a while now. It has finally started to click with me. I guess I just have to read over the SAME things over and over and over again until I finally understand. I figured out how to use g++, and how to make binaries execute system-wide in Linux.

Now I know these are sort of n00bish discoveries, but to me they really helped in the understanding of the C++ language, and the way Linux works.

I found some resources online for learning C++, and will include them at the end of the post.

Ok, now on to the tutorial:

  1. Write your C++ program.(links at the end of the post will show you how)
  2. compile it by running
  3. g++ /path/of/source/file -o /where/you/want/binary/to/end/up

  4. Step 2 generates a binary at /where/you/want/binary/to/end/up. Of course you change this path to wherever you want your binary to go.
  5. Now that you have your binary generated, name it something meaningful and run this command:
    sudo cp /where/you/want/binary/to/end/up /bin
  6. Step 4 copies your binary to where Linux stores all it’s binaries: /bin

Now you have a binary that you can call from the command line!
call it like this:
It’s that simple, all you have to do is type in the program’s name and it will run. Cool, huh?

Learning C++ Resources:
C++ wikibook



  1. […] Go to the author’s original blog: C++ Binaries In Linux: A How-To […]

  2. Marathoning Said:

    Somehow i missed the point. Probably lost in translation đŸ™‚ Anyway … nice blog to visit.

    cheers, Marathoning.

{ RSS feed for comments on this post} · { TrackBack URI }

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: