[net.lang.c++] multiply defined symbols when using complex math library

ables@mcc-pp.UUCP (King Ables) (05/04/86)

I wonder if anyone has seen quite this reaction before?  I've
just installed C++ on an 11/750 running 4.2BSD.  It seems to
work for the generic Hello-world kind of program and a few others
around here.  However, I've been trying to get the example complex
math program to compile and get multiply defined symbols.  I'm
afraid that's indicative of other subtle problems we might have.

On page 1 of PART TWO of the Release notes for 1.0, there's a 
short program example (this is at the beginning of a paper on
Complex Arithmetic in C++):

#include <complex.h>

main()
{
	complex xx;
	complex yy = complex(1,2.718);
	xx = log (yy/3);
	cout << 1+xx;
}

So I took the program and compiled it according to the instructions
back in the section called "Technical Tips" on page 5-4:

CC test.c -lC -lm

and I get:

CC  t.c:
cc   t..c -lC -lm -lC
__ctors: ld:__ctdt.o: multiply defined
__dtors: __ctdt.o: multiply defined

I've broken things down to a pretty low level but don't see why things
are happening like they are.  Has anybody else tried this program or
had this problem?  Thanks for any info.

Also, I'm trying to make a (hopefully) fool-proof list of what needs
to be done to install C++ on a 4.2BSD system.  If I ever convince myself
I understand it fully and really have it right, I'll post it.  In the
mean time, if you're having trouble, I'll be glad to send what I have
so far.  It's mostly made up of info from net.lang.c++ and the README
that comes with the tape.  There are a couple of things I've found, too.
The main use it has is it's ordered... do this, then do this, then do this,
instead of just "here's what's wrong in a fairly random order and in 
seventeen different places!"

-King
ARPA: ables@mcc.arpa
UUCP: {gatech,ihnp4,nbires,seismo,ucbvax}!ut-sally!im4u!milano!mcc-pp!ables
---
All things considered, insanity may be the only reasonable alternative.

jss@ulysses.UUCP (Jerry Schwarz) (05/05/86)

> 
> So I took the program and compiled it according to the instructions
> back in the section called "Technical Tips" on page 5-4:
> 
> CC test.c -lC -lm
> 
> and I get:
> 
> CC  t.c:
> cc   t..c -lC -lm -lC
> __ctors: ld:__ctdt.o: multiply defined
> __dtors: __ctdt.o: multiply defined
> 

This happens when "-lC" occurs twice in the "cc" line.  It doing so
because "CC" always adds it. And you included it explicitly in the "CC" line.  
If you omit "-lC" from the CC invocation this compliant should go away.

Jerry Schwarz
ulysses!jss
Bell Labs, MH