delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/1998/05/02/14:04:36

From: "John M. Aldrich" <fighteer AT cs DOT com>
Newsgroups: comp.os.msdos.djgpp
Subject: Re: linker problem w/ class String
Date: Sat, 02 May 1998 13:57:30 -0400
Organization: Two pounds of chaos and a pinch of salt.
Lines: 31
Message-ID: <354B5E8A.22F8@cs.com>
References: <354c562b DOT 14964878 AT news DOT kfunigraz DOT ac DOT at>
NNTP-Posting-Host: ppp135.cs.net
Mime-Version: 1.0
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp

mimo wrote:
> 
> Error: test.o: In function `__tcf_0':
> Error: test.cc(.text+0x1f): undefined reference to
> `String::~String(void)'
> Error: test.o: In function `main':
> Error: test.cc(.text+0x49): undefined reference to
> `String::String(char const *)'
> test.cc(2) Error: undefined reference to `operator<<(ostream &, String
> const &)'

That's very interesting.  No matter what I did, I was unable to
reproduce your exact results, although I saw plenty of slightly
different errors.  Perhaps it's because I'm using gcc 2.8.0 and you're
still using 2.7.2.1.  In any case, the solution is simple:  you must
link all required C++ libraries when you compile.  To use the String
class, you have to link with both -lstdcxx and -lgpp.

You have two other problems in your code:  in order to use cout, you
should #include <iostream.h> (even though it is included already by
<_string.h>), and void is not a legal return type for main().

-- 
John M. Aldrich, aka Fighteer I <fighteer AT cs DOT com>  UIN# 7406319

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GCS d- s+:- a-->? C++>$ U@>++$ p>+ L>++ E>++ W++ N++ o+>++ K? w(---)
O- M-- V? PS+ PE Y+ PGP- t+(-) 5- X- R+(++) tv+() b+++ DI++ D++ G>++
e(*)>++++ h!() !r !y+()
------END GEEK CODE BLOCK------

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019