LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Please halp I can't compile c++ file (https://www.linuxquestions.org/questions/linux-newbie-8/please-halp-i-cant-compile-c-file-346192/)

malb 07-24-2005 06:08 AM

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. :(

Nylex 07-24-2005 07:17 AM

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.

malb 07-24-2005 07:26 AM

Thanks for reply.

I used "g++ HelloWorld.cpp".

scuzzman 07-24-2005 07:39 AM

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

Nylex 07-24-2005 07:42 AM

Using "g++ HelloWorld.cpp" is fine, just the executable will be called a.out.

malb 07-24-2005 08:26 AM

exactly...

"g++ filename.cpp -o filename" doesn't work either.

scuzzman 07-24-2005 08:16 PM

What are the compiler errors?

foo_bar_foo 07-24-2005 09:43 PM

Quote:

Originally posted by scuzzman
What are the compiler errors?
yea we need exact error messages copy and pasted

Nylex 07-24-2005 10:57 PM

"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.

malb 07-25-2005 06:52 PM

Thanks heaps.

I just re-installed gcc and it's fine now.


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