Solved

How do I compile "Hello World"?

Posted on 2003-11-19
4
1,338 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Application Discovery Service in AWS

In the era of the cloud, customers migrating away from their existing on-premise infrastructure. This requires lots of planning, strategies, and effort to identify their existing resources and determine how best to migrate.  Datacenter migrations happen in four phases -

Question has a verified solution.

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

The purpose of this article is to fix the unknown display problem in Linux Mint operating system. After installing the OS if you see Display monitor is not recognized then we can install "MESA" utilities to fix this problem or we can install additio…
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…
There are cases when e.g. an IT administrator wants to have full access and view into selected mailboxes on Exchange server, directly from his own email account in Outlook or Outlook Web Access. This proves useful when for example administrator want…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…
Suggested Courses

615 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