Solved

How do I compile "Hello World"?

Posted on 2003-11-19
4
1,331 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
Comment Utility
try g++ hello.cpp -o hello
0
 

Author Comment

by:BlaM
Comment Utility
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
Comment Utility
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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Suggested Solutions

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…
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

763 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

6 Experts available now in Live!

Get 1:1 Help Now