🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: gnu.gcc.help
Article #53291

Problems compiling C++ programs with gcc 2.0

#53291
From: M Gordon
Date: Tue, 25 Feb 1992 11:15
54 lines
1889 bytes
I've been trying to use gcc 2.0 to compile simple C++ programs, with
no sucess.  Anything that I try to link with libg++.a has an
undefined symbol error.  The following simple program demonstrates
the problem.


#include <stream.h>

class foo {
	int a,b,c;
  public:
	foo() {a=3;b=4;};
	void mult() {c=a*b;};
	void print() {cout<<"c="<<c;};
};

main(int argc,char **argv)
{
	foo f;

	f.mult();

	f.print();
}


With the command line 

	gcc -I/usr/local/lib/g++-include foo.cc /usr/local/lib/libg++.a

and ignoring the '#pragma once is obsolete' messages the output
is

ld: Undefined symbol
   ___ls__7ostreami
collect: /usr/bin/ld returned 2 exit status


I've installed collect rather than GNU ld so that I can get
dynamically linked programs, but replacing collect with the GNU
linker seems to make no difference.

If I replace the use of streams in foo with a call to printf() the
program compiles and runs quite happily, which is why I think the
problemn is with libg++.  Libg++.a is version 1.37 - would replacing
it with a later version help?

Thanks

-- 
                                                         _   _   _    _   _	
Michael Gordon - mfg@castle.ed.ac.uk OR ee.ed.ac.uk     | |_| |_| |__| |_| |   
                                                        | . . . .      . . |    
It's not an optical illusion, it just looks like one    |_________|~~|_____|    
Technical Details
Message-ID: <18430@castle.ed.ac.uk>
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!edcastle!mfg

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit
X-Google-Thread: 11318c,f747860ef5bd573e,start
X-Google-Attributes: gid11318c,public
X-Google-ArrivalTime: 1992-02-25 22:23:02 PST
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!edcastle!mfg
From: mfg@castle.ed.ac.uk (M Gordon)
Newsgroups: gnu.gcc.help
Subject: Problems compiling C++ programs with gcc 2.0
Message-ID: <18430@castle.ed.ac.uk>
Date: 25 Feb 92 11:15:59 GMT
Organization: Edinburgh University
Lines: 54