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.
|
|
07-24-2005, 07:08 AM
|
#1
|
LQ Newbie
Registered: Jul 2005
Posts: 10
Rep:
|
Please help I can't compile c++ file
Hi
I recetly installed g++ on Fedora. (I used "yum install gcc-c++"). It seemed to be fine but if I try to compile the following very simple c++ code, it just gives me an error mesage sayng "expected constructor, destructor, or type conversion before < token"...
#include <iostream>
using namespace std;
int main()
{
cout << "Hello World \n";
return 0;
}
I'm a newbie and don't know what to do.. Please help me.
Last edited by malb; 07-24-2005 at 08:27 AM.
|
|
|
07-24-2005, 08:17 AM
|
#2
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep:
|
What is the command you're using to compile? The code looks fine to me. Edit: also, this should have been in the Programming forum.
Last edited by Nylex; 07-24-2005 at 08:20 AM.
|
|
|
07-24-2005, 08:26 AM
|
#3
|
LQ Newbie
Registered: Jul 2005
Posts: 10
Original Poster
Rep:
|
Thanks for reply.
I used "g++ HelloWorld.cpp".
|
|
|
07-24-2005, 08:39 AM
|
#4
|
Senior Member
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851
Rep:
|
You should be using:
Code:
g++ SOURCE_FILE.CPP -o OUTPUT_FILE
Where SOURCE_FILE.CPP is the name of your source code, and OUTPUT_FILE is the executable. In the above example, you'd want this command:
Code:
g++ HelloWorld.cpp -o HelloWorld
|
|
|
07-24-2005, 08:42 AM
|
#5
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep:
|
Using "g++ HelloWorld.cpp" is fine, just the executable will be called a.out.
|
|
|
07-24-2005, 09:26 AM
|
#6
|
LQ Newbie
Registered: Jul 2005
Posts: 10
Original Poster
Rep:
|
exactly...
"g++ filename.cpp -o filename" doesn't work either.
|
|
|
07-24-2005, 09:16 PM
|
#7
|
Senior Member
Registered: May 2004
Location: Hilliard, Ohio, USA
Distribution: Slackware, Kubuntu
Posts: 1,851
Rep:
|
What are the compiler errors?
|
|
|
07-24-2005, 10:43 PM
|
#8
|
Senior Member
Registered: Jun 2004
Posts: 2,553
Rep:
|
Quote:
Originally posted by scuzzman
What are the compiler errors?
|
yea we need exact error messages copy and pasted
|
|
|
07-24-2005, 11:57 PM
|
#9
|
LQ Addict
Registered: Jul 2003
Location: London, UK
Distribution: Slackware
Posts: 7,464
Rep:
|
"expected constructor, destructor, or type conversion before < token" comes from the compiler. I found loads of similar errors when searching Google, but no way to fix them. Maybe his GCC is broken, or something.
|
|
|
07-25-2005, 07:52 PM
|
#10
|
LQ Newbie
Registered: Jul 2005
Posts: 10
Original Poster
Rep:
|
Thanks heaps.
I just re-installed gcc and it's fine now.
|
|
|
All times are GMT -5. The time now is 08:32 AM.
|
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
|
|