Gentoo Forums
Gentoo Forums
Gentoo Forums
Quick Search: in
g++ error - undefined reference to `main'
View unanswered posts
View posts from last 24 hours

 
Reply to topic    Gentoo Forums Forum Index Portage & Programming
View previous topic :: View next topic  
Author Message
clockwise
Apprentice
Apprentice


Joined: 24 Aug 2002
Posts: 152
Location: uk

PostPosted: Fri Aug 29, 2003 11:52 pm    Post subject: g++ error - undefined reference to `main' Reply with quote

could someone throw me a bone (even a frikkin' one) here, it's late and i'm pretty sure i'm missing something obvious.

Code:
 $ g++ Vector.cpp -o Vector.o
/usr/lib/gcc-lib/i686-pc-linux-gnu/3.2.3/../../../crt1.o(.text+0x18): In function `_start':
: undefined reference to `main'
collect2: ld returned 1 exit status


thanks.
_________________
"if an injury has to be done to a man it should be so severe that his vengeance need not be feared." - niccolò machiavelli
Back to top
View user's profile Send private message
MJN222
Tux's lil' helper
Tux's lil' helper


Joined: 24 Nov 2002
Posts: 77
Location: Livermore, CA

PostPosted: Sat Aug 30, 2003 12:20 am    Post subject: Reply with quote

What's the code you're trying to compile?

Do you have a main() function defined? g++ is trying to create an executable, so its looking for main() when its linking. Try going this:
Code:
g++ -c -o Vector.o Vector.cpp


That should let it compile...
HTH

edit: The -c tells g++ (or gcc for that matter) that it should only compile, not link.
_________________
Do you lock your car when you leave it out in public? Why not do the same with your computer?
Back to top
View user's profile Send private message
clockwise
Apprentice
Apprentice


Joined: 24 Aug 2002
Posts: 152
Location: uk

PostPosted: Sat Aug 30, 2003 9:24 am    Post subject: Reply with quote

thank you, that was indeed the problem.
_________________
"if an injury has to be done to a man it should be so severe that his vengeance need not be feared." - niccolò machiavelli
Back to top
View user's profile Send private message
Display posts from previous:   
Reply to topic    Gentoo Forums Forum Index Portage & Programming All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum