Go Premium for a chance to win a PS4. Enter to Win

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1340
  • Last Modified:

How do I compile "Hello World"?

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
BlaM
Asked:
BlaM
  • 3
1 Solution
 
sunnycoderCommented:
try g++ hello.cpp -o hello
0
 
BlaMAuthor Commented:
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
 
BlaMAuthor Commented:
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
 
BlaMAuthor Commented:
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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now