Results 1 to 3 of 3
Hello,
I want to get started in C++ programming. I am running Ubuntu 7.10 and first need a compiler. I tried downloading g++ from synaptics package manager but when I ...
- 02-26-2008 #1Just Joined!
- Join Date
- Feb 2008
- Posts
- 19
C++ programming
Hello,
I want to get started in C++ programming. I am running Ubuntu 7.10 and first need a compiler. I tried downloading g++ from synaptics package manager but when I check for its installation under Add/Remove Applications It is not listed. I don't need a tutorial on how to program in C++ since I have and older copy of a book. What I need is advice on how to download and setup the compiler and run a hello world program I created in gedit. Can someone tell me how to download the compiler and run main.cpp (my hello world program) from the tutorial directory in my home directory? I have searched google for over an hour with no luck. Thanks. BTW, here is the program I will run:
#include<iostream>
using namespace std;
int main(){
cout << "hello world!\n";
return 0;
}
- 02-26-2008 #2
If you've searched Google for beginning C++ programming with GCC and haven't found anything, you're obviously not using the right search terms. At any rate, here's what you'll need to get started.
Open up a terminal. Type this:
Assuming you have an internet connection, you will see lots of messages about updates and whatnot. Then when you get your prompt back, type this:Code:sudo apt-get update <enter> Password: <enter your password>
That will get you a working Gcc/G++ enivronment. Now to compile your code from the command line do this:Code:sudo apt-get install build-essential
Assuming you don't have any errors, that will generate a program called a.out. You can run it by typing this:Code:g++ nameofyourfile.cpp
If you want to name our output program something else, use this:Code:./a.out
Replace "nameofyourfile" and "nameofyourexecutable" with whatever applies to you.Code:g++ nameofyourfile.cpp -o nameofyourexecutable
Registered Linux user #270181
TechieMoe's Tech Rants
- 02-26-2008 #3Just Joined!
- Join Date
- Feb 2008
- Posts
- 19
Thanks techieMoe, those were the exact instructions I was looking for. BTW, I was able to find alot of stuff on google, just not what I was looking for. I am still very new to linux but working to overcome that.


Reply With Quote