public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
From: <bley@cs.uni-magdeburg.de>
To: Brent Phillips <brent@lyrastudios.com>
Cc: gcc-help@gcc.gnu.org
Subject: Re: is STL usable with gcc 3.0?
Date: Fri, 17 Aug 2001 06:05:00 -0000	[thread overview]
Message-ID: <15228.50156.388855.314463@wh2-19.st.uni-magdeburg.de> (raw)
In-Reply-To: <5.1.0.14.2.20010816162106.03c96bb0@lyrastudios.com>

| Hi,
| Sorry to send so much email to this list, but I've been having a really 
| horrible with gcc 3.0...the latest is problems getting STL to work with gcc 
| 3.0. On my system (RedHat Linux, RedHat Linux 2.2.18), a basic "hello 
| world" that uses STL crashes in a variety of ways. Take your basic "hello 
| world" program...
| 
| #include <stdio.h>
| #include <stdlib.h>
| #include <unistd.h>
| #include <vector>
| int main(int argc, char** argv) {
|    printf("hello world!\n");  exit(0);
| }
| 
| compiled with default options ("gcc hello.cpp")...
|
| 1) adding the line
| 
| std::vector<int> myvector;
| 
| yields the error
| 
| /tmp/cctISmpm.o: In function `__FRAME_BEGIN__':
| /tmp/cctISmpm.o(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
| collect2: ld returned 1 exit status
 
As a rule of thumb if you intend to compile C++ code, just use the g++
wrapper to compile your code since it is actually necessary to link
code utilizing containers/algorithms etc. of the STL because it links
in the standard C++ library and generally speaking just takes care of
passing the appropriate options to the compiler and linker. If you're
just using 'gcc hello.cpp' at least '-lstdc++' is missing from the
linker options. (`__gxx_personality_v0' is defined in libstdc++)

Next, if you're writing C++ code, it is encouraged to use a special
naming scheme when including headers:

If you're including C headers use '#include <cX>' instead of '#include <X.h>', 
if you're including C++ headers just use '#include <X>'.

This way you will avoid annoying warning messages.

| 2) adding the line
| 
| vector<int> myvector;
| 
| yields the error
| 
| hello.cpp:7: 'vector' is used as a type, but is not defined as a type.

'vector' is declared in the namespace 'std' and you have to specify
the namespace, otherwise it won't work...

| 3) adding the lines
| 
| typedef std::vector<int> mytype_t;
| 
| mytype_t myvector;
| 
| yields the error
| 
| /tmp/cc2HrKVq.o: In function `__FRAME_BEGIN__':
| /tmp/cc2HrKVq.o(.eh_frame+0x12): undefined reference to `__gxx_personality_v0'
| collect2: ld returned 1 exit status
| 
| Please advise...this is driving me insane!
| 
| thanks so much
| 
| Brent

Claudio

      parent reply	other threads:[~2001-08-17  6:05 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2001-08-16 16:28 Brent Phillips
2001-08-16 18:09 ` lange92
2001-08-16 18:24 ` Alexandre Oliva
2001-08-17  6:05 ` bley [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=15228.50156.388855.314463@wh2-19.st.uni-magdeburg.de \
    --to=bley@cs.uni-magdeburg.de \
    --cc=brent@lyrastudios.com \
    --cc=gcc-help@gcc.gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).