public inbox for gcc-help@gcc.gnu.org
 help / color / mirror / Atom feed
* is STL usable with gcc 3.0?
@ 2001-08-16 16:28 Brent Phillips
  2001-08-16 18:09 ` lange92
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Brent Phillips @ 2001-08-16 16:28 UTC (permalink / raw)
  To: gcc-help

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

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.

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






^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: is STL usable with gcc 3.0?
  2001-08-16 16:28 is STL usable with gcc 3.0? Brent Phillips
@ 2001-08-16 18:09 ` lange92
  2001-08-16 18:24 ` Alexandre Oliva
  2001-08-17  6:05 ` bley
  2 siblings, 0 replies; 4+ messages in thread
From: lange92 @ 2001-08-16 18:09 UTC (permalink / raw)
  To: Brent Phillips; +Cc: gcc-help

Isn't the STL for C++??

On Thu, 16 Aug 2001, Brent Phillips wrote:

> ...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...

<snip "neuter" code which cannot be distinguished between C and C++>

> 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

"gxx" everywhere I've seen it referred to (makefiles, mostly) is talking
about C++.

further, the extension .cpp would suggest it's C++. Try "g++ hello.cpp".


^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: is STL usable with gcc 3.0?
  2001-08-16 16:28 is STL usable with gcc 3.0? Brent Phillips
  2001-08-16 18:09 ` lange92
@ 2001-08-16 18:24 ` Alexandre Oliva
  2001-08-17  6:05 ` bley
  2 siblings, 0 replies; 4+ messages in thread
From: Alexandre Oliva @ 2001-08-16 18:24 UTC (permalink / raw)
  To: Brent Phillips; +Cc: gcc-help

On Aug 16, 2001, Brent Phillips <brent@lyrastudios.com> wrote:

> 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

Use g++ to link C++ code, so that libstdc++ is implicitly linked in.
Some C++-specific symbols that used to be in libgcc were moved to
libstdc++ in GCC 3.0.

> 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.

std:: is significant in GCC 3.0, and <vector> declares only
std::vector, unlike <vector.h>, that brings std::vector into the
global namespace.

-- 
Alexandre Oliva   Enjoy Guarana', see http://www.ic.unicamp.br/~oliva/
Red Hat GCC Developer                  aoliva@{cygnus.com, redhat.com}
CS PhD student at IC-Unicamp        oliva@{lsd.ic.unicamp.br, gnu.org}
Free Software Evangelist    *Please* write to mailing lists, not to me

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: is STL usable with gcc 3.0?
  2001-08-16 16:28 is STL usable with gcc 3.0? Brent Phillips
  2001-08-16 18:09 ` lange92
  2001-08-16 18:24 ` Alexandre Oliva
@ 2001-08-17  6:05 ` bley
  2 siblings, 0 replies; 4+ messages in thread
From: bley @ 2001-08-17  6:05 UTC (permalink / raw)
  To: Brent Phillips; +Cc: gcc-help

| 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

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2001-08-17  6:05 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-08-16 16:28 is STL usable with gcc 3.0? Brent Phillips
2001-08-16 18:09 ` lange92
2001-08-16 18:24 ` Alexandre Oliva
2001-08-17  6:05 ` bley

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).