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 |
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.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
03-24-2006, 03:46 AM
|
#1
|
|
Member
Registered: Mar 2005
Distribution: slackware, LFS
Posts: 204
Rep:
|
Hello World linking Errors
Hello I tying to to learn C++ I'm using the "SAM'S Teach Yourself C++ in 24 HOURS:THIRD EDITION" book. I have GCC-3.3.4.
I tried to compile the HELLO.CPP file:
Code:
#include <iostream>
int main()
{
std::cout << "Hello World!/n";
return 0;
}
But when I do: I get:
Code:
/tmp/ccO9otYD.o(.text+0xd): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::size() const'
/tmp/ccO9otYD.o(.text+0x60): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/ccO9otYD.o(.text+0x9f): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/ccO9otYD.o(.text+0xce): In function `std::__verify_grouping(char const*, unsigned int, std::basic_string<char, std::char_traits<char>, std::allocator<char> > const&)':
: undefined reference to `std::basic_string<char, std::char_traits<char>, std::allocator<char> >::operator[](unsigned int) const'
/tmp/ccO9otYD.o(.text+0x127): In function `main':
: undefined reference to `std::cout'
/tmp/ccO9otYD.o(.text+0x12c): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::operator<< <std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&, char const*)'
/tmp/ccO9otYD.o(.text+0x155): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init()'
/tmp/ccO9otYD.o(.text+0x186): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init()'
/tmp/ccO9otYD.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status
I don't understand any of this:
Anyone have a suggetion?
|
|
|
|
03-24-2006, 04:05 AM
|
#2
|
|
Senior Member
Registered: Nov 2002
Location: Edmonton AB, Canada
Distribution: Gentoo x86; Gentoo PPC; Gentoo Sparc64; FreeBSD; OS X; Solaris
Posts: 3,731
Rep:
|
gcc is a "C" compiler. Try "g++ HELLO.CPP".
|
|
|
|
03-24-2006, 04:13 AM
|
#3
|
|
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530
Rep: 
|
Use a backslash instead:
Code:
int main()
{
std::cout << "Hello World!\n";
return 0;
}
Also, I'd recommend compiling with"
Code:
g++ -Wall -pedantic -o hello hello.cpp
This makes sure that: - The executable will have the name "hello" instead of "a.out".
- You get all warnings about your code
|
|
|
|
03-24-2006, 04:16 AM
|
#4
|
|
Moderator
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris10, Solaris 11, Ubuntu, OL
Posts: 9,311
|
and don't use uppercase in file names/extensions, that's ugly.
|
|
|
|
03-24-2006, 04:16 AM
|
#5
|
|
Member
Registered: Mar 2005
Distribution: slackware, LFS
Posts: 204
Original Poster
Rep:
|
Thank you very very much!
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 03:10 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
|
|