Solved

How do I compile "Hello World"?

Posted on 2003-11-19
4
1,333 Views
Last Modified: 2010-04-21
Okay, this might sound a bit ridiculous for experts, but I'm a Windows-Slave, so please have a heart and help and don't just laugh;)

This is my source:

---
#include <iostream>
using namespace std;

int main()
{

    cout << "Hello Glossary" << endl;

    return 0;
}
---

Easy, huh? I type in

> gcc hello.cpp -o hello

and all I get is...

/tmp/ccUgIjOM.o(.text+0x14): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >& std::endl<char, std::char_traits<char> >(std::basic_ostream<char, std::char_traits<char> >&)'
/tmp/ccUgIjOM.o(.text+0x21): In function `main':
: undefined reference to `std::cout'
/tmp/ccUgIjOM.o(.text+0x26): 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/ccUgIjOM.o(.text+0x2f): In function `main':
: undefined reference to `std::basic_ostream<char, std::char_traits<char> >::operator<<(std::basic_ostream<char, std::char_traits<char> >& (*)(std::basic_ostream<char, std::char_traits<char> >&))'
/tmp/ccUgIjOM.o(.text+0x5c): In function `__static_initialization_and_destruction_0(int, int)':
: undefined reference to `std::ios_base::Init::Init[in-charge]()'
/tmp/ccUgIjOM.o(.text+0x8b): In function `__tcf_0':
: undefined reference to `std::ios_base::Init::~Init [in-charge]()'
/tmp/ccUgIjOM.o(.eh_frame+0x11): undefined reference to `__gxx_personality_v0'
collect2: ld returned 1 exit status


What is missing? What do I need to install (keep in mind: I'm just a "Windowser", so speak SuSe RPM with me ;)
0
Comment
Question by:BlaM
  • 3
4 Comments
 
LVL 45

Accepted Solution

by:
sunnycoder earned 160 total points
ID: 9778732
try g++ hello.cpp -o hello
0
 

Author Comment

by:BlaM
ID: 9778791
With g++ I get

/usr/lib/gcc-lib/i486-suse-linux/3.3/../../../../i486-suse-linux/bin/ld: cannot find -lgcc_s
collect2: ld returned 1 exit status

0
 

Author Comment

by:BlaM
ID: 9778901
Maybe this might be interesting to help solving the problem:

g++ (GCC) 3.3 20030226 (prerelease) (SuSE Linux)
Copyright (C) 2002 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

GNU ld version 2.13.90.0.18 20030121 (SuSE Linux)
Copyright 2002 Free Software Foundation, Inc.
This program is free software; you may redistribute it under the terms of
the GNU General Public License.  This program has absolutely no warranty.

0
 

Author Comment

by:BlaM
ID: 9780512
Oki... Finally:

Your (sunnycoder) suggestion solved my problem which lead my to another one, which I meanwhile solved myself.

Means: You get the points ;)

And for everyone else, who might have the "ld: cannot find -lgcc_s" problem:
http://lists.debian.org/debian-gcc/2001/debian-gcc-200106/msg00079.html

The file libgcc_s.so (/usr/lib/ in my system) links to the latest version of the file - or at least it should do so. It pointed to nowhere, so I had do fix the link to point somewhere more useful ;)
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Have you ever been frustrated by having to click seven times in order to retrieve a small bit of information from the web, always the same seven clicks, scrolling down and down until you reach your target? When you know the benefits of the command l…
The purpose of this article is to demonstrate how we can upgrade Python from version 2.7.6 to Python 2.7.10 on the Linux Mint operating system. I am using an Oracle Virtual Box where I have installed Linux Mint operating system version 17.2. Once yo…
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

932 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now