Solved

How do I compile "Hello World"?

Posted on 2003-11-19
4
1,335 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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

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…
Established in 1997, Technology Architects has become one of the most reputable technology solutions companies in the country. TA have been providing businesses with cost effective state-of-the-art solutions and unparalleled service that is designed…
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

856 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