LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 07-21-2009, 08:17 AM   #1
Akheron
LQ Newbie
 
Registered: May 2009
Posts: 26

Rep: Reputation: 16
programming C++ in linux [SOLVED]


does gcc compile files written in C++? I assume you run a text editor to put in the commands? Or is there a good program available for linux that i can use for this? Does anyone recommend python? I herd it's mostly good for scripts.

Last edited by Akheron; 07-21-2009 at 03:27 PM.
 
Old 07-21-2009, 11:14 AM   #2
tronayne
Senior Member
 
Registered: Oct 2003
Location: Northeastern Michigan, where Carhartt is a Designer Label
Distribution: Slackware 32- & 64-bit Stable
Posts: 3,541

Rep: Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065Reputation: 1065
Yes, you can write a C++ program (using a text editor) and compile it with g++ (the GNU C++ compiler). One of, for example, the O'Reilly books on C++ programming in a Linux environment would be a good investment; see http://oreilly.com.

A look at the official Python web site, http://www.python.org, might give you some idea what you can do with Python.
 
Old 07-21-2009, 11:26 AM   #3
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
On *nix most serious hard core types will use a vi (text editor) and make files
for C programming rather than a big heavy environment.
It's not for obstinate reasons, or being awkward or clever. it's because it's quicker and more efficient.
the downside is it takes time to learn.
Most will probably use something like gvim with syntax highlighting though.



python is not rubbish.
perl is another excellent scripting tool.
as is shell scripting.


it depends muchly on what you are trying to achieve.
choose the best tool for the job.

if you learn:
1. shell scripting
2. high level scripting (perl,python or similar)
3. C or maybe C++.

you will have a tool for 95% of tasks.
 
Old 07-21-2009, 11:40 AM   #4
Akheron
LQ Newbie
 
Registered: May 2009
Posts: 26

Original Poster
Rep: Reputation: 16
Thanks guys. im not too new with programming but ive never really done it in linux before. never found the need to untill now. my ultimate goal is to create a simple iso/data/video burning tool run through the console. ive always favored running things through the console plus i cant seem to find a burning tool i like so im going to make my own. itll take time but ill learn alot through the process.

ok i run g++ cout.cpp and it gives me a file a.out. i run it via the command "./a.out". i dont know the extension out. is there a way to compile it as a .sh or .bin?

Last edited by Akheron; 07-21-2009 at 12:15 PM.
 
Old 07-21-2009, 12:40 PM   #5
bigearsbilly
Senior Member
 
Registered: Mar 2004
Location: england
Distribution: Mint, Armbian, NetBSD, Puppy, Raspbian
Posts: 3,515

Rep: Reputation: 239Reputation: 239Reputation: 239
well the easiest way, I always use is to use make and the default rules.

using your example, make cout should compile an executable
called cout

for example on my BSD machine:

Code:
 
# make empty file 
$ touch cout.cpp
$ make cout
c++ -O2 -fno-strict-aliasing -pipe  cout.cpp  -o cout
obviously you get an error as it's an empty file.

or if you prefer:
Code:
g++ cout.cpp -o cout.bin
.sh extension usually means a shell script

the a.out default is an historical anachronism.
god knows why it's still default.

try man gcc

gcc -M
gcc -E
are quite interesting

Last edited by bigearsbilly; 07-21-2009 at 12:45 PM.
 
Old 07-21-2009, 12:48 PM   #6
Akheron
LQ Newbie
 
Registered: May 2009
Posts: 26

Original Poster
Rep: Reputation: 16
thank you very much you answered my question perfectly. i appreciate everyones help!
 
  


Reply



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



LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 01:20 PM.

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
Open Source Consulting | Domain Registration