LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 08-27-2012, 03:38 AM   #1
gerdy
Member
 
Registered: May 2012
Posts: 69

Rep: Reputation: Disabled
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++?
 
Old 08-27-2012, 03:42 AM   #2
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 635

Rep: Reputation: 186Reputation: 186
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.
 
Old 08-27-2012, 03:42 AM   #3
knudfl
LQ 5k Club
 
Registered: Jan 2008
Location: Copenhagen, DK
Distribution: pclos2016, Slack14.1 Deb Jessie, + 50+ other Linux OS, for test only.
Posts: 16,276

Rep: Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156Reputation: 3156
Ubuntu : sudo apt-get install g++

...
 
Old 08-27-2012, 03:44 AM   #4
gerdy
Member
 
Registered: May 2012
Posts: 69

Original Poster
Rep: Reputation: Disabled
I'm using Ubuntu 12.04. and after I do sudo apt-get G++, how do I run the programs I create?
 
Old 08-27-2012, 03:49 AM   #5
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,512

Rep: Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435
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.
 
Old 08-27-2012, 03:49 AM   #6
gerdy
Member
 
Registered: May 2012
Posts: 69

Original Poster
Rep: Reputation: Disabled
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?
 
Old 08-27-2012, 03:54 AM   #7
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,512

Rep: Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435
see getting started on this page: http://www3.wooster.edu/cs/studentRes/gccTutorial.php
 
Old 08-27-2012, 03:58 AM   #8
gerdy
Member
 
Registered: May 2012
Posts: 69

Original Poster
Rep: Reputation: Disabled
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.
 
Old 08-27-2012, 04:01 AM   #9
gerdy
Member
 
Registered: May 2012
Posts: 69

Original Poster
Rep: Reputation: Disabled
thanks for that link.
 
Old 08-27-2012, 04:02 AM   #10
pan64
LQ Guru
 
Registered: Mar 2012
Location: Hungary
Distribution: debian/ubuntu/suse ...
Posts: 8,512

Rep: Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435Reputation: 2435
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
 
Old 08-27-2012, 04:16 AM   #11
414N
Member
 
Registered: Sep 2011
Location: Italy
Distribution: Slackware
Posts: 635

Rep: Reputation: 186Reputation: 186
Also, please note that C++ source files should have .cpp suffix, not .c.
 
1 members found this post helpful.
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help Starting qt Programming binarybob0001 Programming 6 11-16-2007 07:40 PM
Starting X Programming binarybob0001 Programming 9 01-10-2006 02:22 AM
Starting Linux Programming... Where? slack&lovinit Programming 2 12-14-2005 03:40 AM
Starting php programming jagman Programming 8 09-02-2005 05:27 AM
starting 3d programming Tafta Programming 2 01-30-2004 10:12 AM


All times are GMT -5. The time now is 10:10 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration