LinuxQuestions.org
Visit Jeremy's Blog.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software
User Name
Password
Linux - Software This forum is for Software issues.
Having a problem installing a new program? Want to know which application is best for the job? Post your question in this forum.

Notices


Reply
  Search this Thread
Old 01-05-2009, 12:40 PM   #1
phoenix_wolf
Member
 
Registered: Apr 2004
Distribution: Debian
Posts: 177

Rep: Reputation: 30
Learning C++ on linux..


Greetings..
I am trying to lean C++ and I want to do it on linux I seem to have the program because when I save the file as .cpp the letters change collars as they did on windows when I was studding on it.. (any how I am thinking that all I need to do to compile it is run it on Terminal, how ever I do not know how to do that what do I type?...
thank you all..
 
Old 01-05-2009, 12:44 PM   #2
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
To compile a C++ source file (assuming there is is only one source file):
Code:
$ g++ -o progName main.cpp
The "-o progName" section means that progName will be the created, executable file. If you do not specify the "-o" option, the executable will be called "a.out".

For more than one file, just keep listing them after main.cpp. And "main.cpp" is just the assumption of the main source file for your program.

Last edited by indienick; 01-05-2009 at 12:45 PM.
 
Old 01-05-2009, 12:51 PM   #3
jf.argentino
Member
 
Registered: Apr 2008
Location: Toulon (France)
Distribution: FEDORA CORE
Posts: 493

Rep: Reputation: 50
Google for "C++ linux tutorial", I'm sure you'll find plenty of.

Some advices:
-Understand what "objects oriented programming" is, this is the most (IMHO) difficult part of the learning process, and finally can be understand with a "easier" language like python or java, I really advice you to not learning C++ if you're a programming beginner.
-Learn how the compilation process work, the only efficient way to do this is to write your Makefile by hand, and don't use IDE like KDevelop, Anjuta or other Eclipse. When you'll understand what are dependencies, linkage and others compilation black magics, then try some IDE and pick the one you prefer.
-I repeat it: I think that C++ is really a bad language for a beginner, its syntax is awful, it's easy to make procedural (read not object oriented programming) and you're easily disturbed by problems like memory allocation and others...
 
Old 01-05-2009, 01:12 PM   #4
johnsfine
LQ Guru
 
Registered: Dec 2007
Distribution: Centos
Posts: 5,286

Rep: Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194Reputation: 1194
Quote:
Originally Posted by phoenix_wolf View Post
I seem to have the program because when I save the file as .cpp the letters change collars as they did on windows when I was studding on it.
If I understand you correctly, you think the behavior of some text editor when it sees the extension .cpp indicates that you have the required Debian packages installed for compiling C++ programs.

I don't know if you have the required packages installed. I don't think the behavior of that text editor tells you if you have the right packages installed.

Probably some Debian expert here can tell you which packages you need (though in the Synaptic package manager it should be pretty obvious).

Quote:
Originally Posted by jf.argentino View Post
Google for "C++ linux tutorial", I'm sure you'll find plenty of.
I think that's good advice and not too far off from what the OP needs.

Quote:
I really advice you to not learning C++ if you're a programming beginner.
I sure hope you don't manage to sidetrack this thread into another fight over that question. I strongly disagree, but I don't want to argue it here. That's not the advice the OP is looking for.

Quote:
-Learn how the compilation process work, the only efficient way to do this is to write your Makefile by hand, and don't use IDE like KDevelop, Anjuta or other Eclipse.
I disagree with that advice also (though that advice is not off topic to the original question).

My best guess based on what the OP said is that he would be better off installing and using some IDE such as KDevelop.

I think the question implied (a bit unclearly) by the OP, was which Debian packages should be installed in order to compile C++ and help in learning C++.

Hopefully someone who knows Debian package names will give a clearer answer.

Last edited by johnsfine; 01-05-2009 at 01:27 PM.
 
Old 01-05-2009, 01:19 PM   #5
phoenix_wolf
Member
 
Registered: Apr 2004
Distribution: Debian
Posts: 177

Original Poster
Rep: Reputation: 30
thank you all..
and thankyou jf.argentino for the suggestions that I do python or java first.. Ill go and search those out (just one question about them is there any that is a better one to start with or does it matter?)...
 
Old 01-05-2009, 01:19 PM   #6
indienick
Senior Member
 
Registered: Dec 2005
Location: London, ON, Canada
Distribution: Arch, Ubuntu, Slackware, OpenBSD, FreeBSD
Posts: 1,853

Rep: Reputation: 65
The big difference between Windows and Linux when it comes to filetypes (MIME types), is that it becomes application-centric to recognize various MIME types in Linux and in Windows, MIME types are (usually) provided by the application that uses them.

Python is super-easy, so if you have never done any programming before, Python is probably going to be your best bet.

Personally, I do not like Python, but I do write in Java a fair bit - its syntax and semantics are much closer to C++ than Python is.

Last edited by indienick; 01-05-2009 at 01:21 PM.
 
  


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
LXer: Foresight Linux 1.0 Kids Edition ScreenShots, Linux built for learning LXer Syndicated Linux News 0 10-11-2008 04:40 AM
Learning Linux by using it? maker2 Linux - Distributions 9 05-25-2008 10:02 PM
Learning about Linux Mr.Carioca Linux - Newbie 24 02-01-2008 06:21 AM
learning linux! bamdev Linux - Newbie 2 11-27-2006 02:00 AM
Learning linux srivats Linux - Newbie 3 09-18-2006 08:27 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software

All times are GMT -5. The time now is 03:32 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