beginners help on linking libraries in gcc - hello world????

Stephano Mariani sk.mail@btinternet.com
Sun Jan 27 12:46:00 GMT 2002


 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Either add "-lstdc++" to your link command line, or use g++ instead
of gcc.

Stephano Mariani

- -----Original Message-----
From: gcc-help-owner@gcc.gnu.org [mailto:gcc-help-owner@gcc.gnu.org]
On Behalf Of David Crotin
Sent: Sunday, 27 January 2002 11 44
To: gcc-help@gcc.gnu.org
Subject: beginners help on linking libraries in gcc - hello world????

Hello whomever receives this e-mail.  I am a gcc ( and c++ ) neophyte
just
trying to get started with "hello, world" on a Solaris 2.6 system.  I
have
completed the following installations with pkgadd:

1. gcc-3.0.3
2. binutils-2.11.2
	I was careful not to over-write any gcc-3.0.3 files when installing
binutils.

Everything was installed in /usr/local/...  The libraries and header
files
are all there.

I have written the basic hello, world:

#include <iostream.h>

main()
{
	cout <<"Hello World\n";
	return (0);
}

and tried to compile but could not link, to no avail.  The errors are
extensive.  I also tried eliminating any actual code:


#include <iostream.h>

main()
{
}

and was able to compile, but not link.  The output was shorter, as
follows:

/var/tmp/cc7X5d9Y.o: In function
`__static_initialization_and_destruction_0(int, int)':
/var/tmp/cc7X5d9Y.o(.text+0x1a4): undefined reference to
`std::ios_base::Init::Init()'
/var/tmp/cc7X5d9Y.o(.text+0x1dc): undefined reference to
`std::ios_base::Init::~Init()'
/var/tmp/cc7X5d9Y.o(.eh_frame+0x11): undefined reference to
`__gxx_personality_v0'
collect2: ld returned 1 exit status

I have tried to figure out exactly what is wrong, but the amount of
information to sift through describing how gcc, ld, etc., work is
overwhelming.

Can you please give me some direction onthis undoubtedly trivial
problem??


Thanks.


David Crotin


-----BEGIN PGP SIGNATURE-----
Version: PGP 7.1.1
Comment: Use PGP or GNUPG

iQA/AwUBPFRnB2gk66Ms+o9zEQL3HwCg3guGV0dXqZlcz/1JQhRLxzynZmwAoMmD
xPVYU31vS6WhpwRjtzqEPUcj
=tlm/
-----END PGP SIGNATURE-----




More information about the Gcc-help mailing list