Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's this is the place! |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
08-27-2012, 03:38 AM
|
#1
|
Member
Registered: May 2012
Posts: 69
Rep:
|
starting C++ programming
I have been reading C++ tutorials and stuff online and want to start making my own programs and stuff. one of the first things I noticed is that I have to have a compiler. the page I read mentioned that most GNU os's come with a compiler. I can't find any kind of compiler right now. So where do I start for the compilers and what not for C++?
|
|
|
08-27-2012, 03:42 AM
|
#2
|
Member
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 651
Rep:
|
You should at least tell which distro you're using for us to be of any help.
Assuming you're on Ubuntu, you need to install the build-essential package.
You can find some more info here.
|
|
|
08-27-2012, 03:42 AM
|
#3
|
LQ 5k Club
Registered: Jan 2008
Location: Copenhagen DK
Distribution: PCLinuxOS2023 Fedora38 + 50+ other Linux OS, for test only.
Posts: 17,519
|
Ubuntu : sudo apt-get install g++
...
|
|
|
08-27-2012, 03:44 AM
|
#4
|
Member
Registered: May 2012
Posts: 69
Original Poster
Rep:
|
I'm using Ubuntu 12.04. and after I do sudo apt-get G++, how do I run the programs I create?
|
|
|
08-27-2012, 03:49 AM
|
#5
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,484
|
when you create a program you will use an option like this: g++ -o <filename> <other options>. This filename is your result and is executable, so you can run it just by typing the name.
For example g++ -o helloworld helloworld.c will create a file named helloworld and you can execute it as: helloworld.
|
|
|
08-27-2012, 03:49 AM
|
#6
|
Member
Registered: May 2012
Posts: 69
Original Poster
Rep:
|
thanks for the sudo apt-get install g++. what do I save my files as for g++?
---------- Post added 08-27-12 at 12:20 PM ----------
awesome. thank you! so .C is the extension?
|
|
|
08-27-2012, 03:54 AM
|
#7
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,484
|
|
|
|
08-27-2012, 03:58 AM
|
#8
|
Member
Registered: May 2012
Posts: 69
Original Poster
Rep:
|
so I made the famous helloworld.C file and saved it on my desktop, when I try to compile it, and do the g++ -o hello.C, it came up with
g++ -o /home/ethan/Desktop/hello.C
g++: fatal error: no input files
compilation terminated.
please note-top line is what I input.
|
|
|
08-27-2012, 04:01 AM
|
#9
|
Member
Registered: May 2012
Posts: 69
Original Poster
Rep:
|
thanks for that link.
|
|
|
08-27-2012, 04:02 AM
|
#10
|
LQ Addict
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 23,484
|
gerdy, you need to specify both the source and the resuld files, like:
g++ -o <result> <sources>
In your example you have not specified any source (or input) file, just an output file which was /home/ethan/Desktop/hello.C
|
|
|
08-27-2012, 04:16 AM
|
#11
|
Member
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 651
Rep:
|
Also, please note that C++ source files should have .cpp suffix, not .c.
|
|
1 members found this post helpful.
|
All times are GMT -5. The time now is 08:53 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|