Right now I’m posting this from my old laptop that I’m going use as a testbed for my programing stuff. I’m just bored right now………………….and had nothing better to do
Archive for May 23, 2008
Xubuntu Testbed
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:
- Write your C++ program.(links at the end of the post will show you how)
- compile it by running
- 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.
- 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 - Step 4 copies your binary to where Linux stores all it’s binaries: /bin
g++ /path/of/source/file -o /where/you/want/binary/to/end/up
Now you have a binary that you can call from the command line!
call it like this:programname
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:
isocotton.com
cplusplus.com
C++ wikibook