LinuxQuestions.org
Review your favorite Linux distribution.
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 08-27-2001, 09:25 AM   #1
Breezwell
Member
 
Registered: Apr 2001
Location: Chicago
Distribution: Gentoo 1.4
Posts: 214

Rep: Reputation: 30
Need good Linux C++ Compiler


I have been using gcc for C programming, but cannot seem to get any C++ code to compile. I installed the gcc++ tarball that came with my Mandrake 7.2 and Red Hat 7.2 distro's, but no luck.

I use the following command line statement to compile my C code:

gcc -o <program> <program.c>

This works just fine.
Do I use the same statement for C++?:

gcc -o <program> <program.cpp>


I really dont want to have to use any Window$ applications to do this.

Thanks for any help .
 
Old 08-27-2001, 11:02 AM   #2
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
compilers like gcc distinguish (primarily) between c and c++ by their fiel extension. .c files are assumed to be standard c, whilst .cc files are c++. you should not need to change the compiler you use.

i think that you can use the 'c++' compiler which defaults to c++ code i presume.

AHHH.. cpp cplusplus... of course! why didn't i realise that sooner?? same went for gtk-- / gtkmm. and of course realising why c++ is called so took even longer.. DOH! :-)
 
Old 08-27-2001, 11:49 AM   #3
Breezwell
Member
 
Registered: Apr 2001
Location: Chicago
Distribution: Gentoo 1.4
Posts: 214

Original Poster
Rep: Reputation: 30
Apparently I was using the wrond command line statement.
On my system, I needed to use the following:

c++ -o <program> <program.c>

The documentation at the GCC site covers this issue very well.
 
Old 08-27-2001, 11:59 AM   #4
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
well, the point is that you shouldn't need to do that, as having the non-standard file extension makes poor programming practice and so forth...
 
Old 08-27-2001, 12:24 PM   #5
Breezwell
Member
 
Registered: Apr 2001
Location: Chicago
Distribution: Gentoo 1.4
Posts: 214

Original Poster
Rep: Reputation: 30
I am saving my programs with a .cpp extension though.
I am not saving with any sort of odd file extension.
 
Old 08-27-2001, 12:54 PM   #6
acid_kewpie
Moderator
 
Registered: Jun 2001
Location: UK
Distribution: Gentoo, RHEL, Fedora, Centos
Posts: 43,417

Rep: Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985Reputation: 1985
hey.. sorry, but in your reply you used <program.c>, that's all!
 
Old 08-27-2001, 04:11 PM   #7
Breezwell
Member
 
Registered: Apr 2001
Location: Chicago
Distribution: Gentoo 1.4
Posts: 214

Original Poster
Rep: Reputation: 30
Ah, my bad.

Thanks for your help though.
 
Old 08-28-2001, 05:43 PM   #8
isajera
Senior Member
 
Registered: Jun 2001
Posts: 1,635

Rep: Reputation: 45
...there's also g++.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Good C++ compiler MbowerARA Red Hat 4 01-28-2005 12:22 PM
need good c++ compiler for suse sles 8 prince amir Programming 1 11-13-2004 02:49 PM
Whats a good compiler for linux? Jmcatch742 Programming 2 11-08-2004 01:47 AM
good compiler Longinus Programming 4 02-24-2004 11:17 AM
Is there a good Scheme Interpreter/Compiler for Slack? CodeWarrior Slackware 1 07-05-2003 06:20 PM

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

All times are GMT -5. The time now is 06:49 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
Open Source Consulting | Domain Registration