From: fuhrmann@weyl.wias-berlin.de (Juergen Fuhrmann)
Subject: g++ 2.6.2 code not linked
Date: 1995/11/08 [thread overview]
Message-ID: <FUHRMANN.95Nov8142611@weyl.wias-berlin.de> (raw)
There seems to be a problem with g++-2.6.2 on Digital Unix. I don't know if it
is gone with 2.7.0 (I'm waiting for 2.7.1). Some programs which use more of
iostream.h than simply 'cout <<...' do not link successfully. An example is
attached below.
I suppose it's a problem with ld not understanding symbols with "..ng" at the end.
Juergen
Juergen Fuhrmann fuhrmann@wias-berlin.de
Weierstrass Institute for Applied Analysis and Stochastics (WIAS)
Mohrenstrasse 39 D-10117 Berlin, Germany
phone: (49) 030 20377 560 fax: (49) 030 2044975
/////////////////////////////////
#include <iostream.h>
#include <iomanip.h>
#include <string.h>
//
// This program does compile, link and run successfully on
// SunOS 4.1.2 1 sun4m g++ 2.6.2
// IRIX 5.3 IP17 mips g++ 2.6.2
// IRIX 5.3 IP17 mips Edison Design Group C/C++ Front End, version 2.19
// OSF1 V3.2 148 alpha DEC C++ V5.0-3 for DEC OSF/1 (Alpha)
//
// It generates the following error with
//
// OSF1 V3.2 148 alpha g++ 2.6.2
//
// ld:
// [...]
// Unresolved:
// __3iosP9streambufP7ostream..ng
// _$_7ostream..ng
// [...]
// These symbols are definitely in libg++.a (checked with nm).
//
// I did not find any workaround.
static ostream *prt=0;
static ostream *out=&cout;
static ostream *err=&cerr;
#define PREFIXLEN 15
class dbgstreambuf : public streambuf
{
private:
int doprefix;
public:
char name[16];
char prefix[PREFIXLEN+2];
int is_on;
dbgstreambuf(char *xname=0, int initial_state=1);
int overflow(int ch);
void off() { is_on=0; }
void on() { is_on=1; }
};
dbgstreambuf::dbgstreambuf(char *xname,int initial_state) : streambuf()
{
if (xname!=0)
{
int i,p0;
strcpy(name,xname);
p0=PREFIXLEN-strlen(name);
if (p0<0) *err << "Warning: debug flag name " << xname << " too long!\n";
for (i=0;i<p0;i++)
prefix[i]=' ';
for (;i<PREFIXLEN;i++)
prefix[i]=*xname++;
prefix[i++]=':';
prefix[i++]=' ';
prefix[i++]='\0';
}
else
{
*name='\0';
}
is_on=initial_state;
doprefix=1;
}
int dbgstreambuf::overflow (int c)
{
if (!is_on) return 0;
if (doprefix)
{
if (out) *out<< prefix;
if (prt) *out<< prefix;
doprefix=0;
}
if ((char)c=='\n')
{
if (out)
{
*out << '\n';
out->flush();
}
if (prt)
{
*prt << '\n';
prt->flush();
}
if (*name!='\0') doprefix=1;
}
else
{
if (out) *out << (char)c;
if (prt) *prt<<(char)c;
}
return 0;
}
///////////////////////////////////////////////////
class dbgstream : public dbgstreambuf, public ostream
{
public:
dbgstream(char *name, int initial_state ) :
dbgstreambuf(name,initial_state ),
ostream(this)
{ };
operator void*(){ return (void*) is_on;}
int operator!() { return !is_on; }
};
static dbgstream tstr("test",1);
void main(void)
{
tstr << "hello world\n" << " das ist der test\n";
tstr.off();
if (tstr) tstr << sizeof(tstr) << '\n';
}
--
Juergen Fuhrmann fuhrmann@wias-berlin.de
Weierstrass Institute for Applied Analysis and Stochastics (WIAS)
Mohrenstrasse 39 D-10117 Berlin, Germany
phone: (49) 030 20377 560 fax: (49) 030 2044975
* Bad News is No News *
reply other threads:[~1995-11-08 5:00 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
read-only archive
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox