public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* multiple definitions of....
@ 1997-12-10  3:46 Orn E. Hansen
  0 siblings, 0 replies; 3+ messages in thread
From: Orn E. Hansen @ 1997-12-10  3:46 UTC (permalink / raw)
  To: egcs

  As was reported yesterday, the new snapshot has a problem with strings.
Now, it isn't difficult to compile bastring.cc as a template class, and
include it, but in a program I get this additional error

----
Balance.o(.data+0x20): multiple definition of `__default_alloc_template<false,
0>::free_list'
main.o(.data+0x34c): first defined here
collect2: ld returned 1 exit status
make: *** [bokhald] Error 1
----

  Is there a way to neatly bypass this error, until a solution to the
above has been done (I assume one will be done?).

----------------------------------------------------------------------------
Orn Einar Hansen                         oe.hansen@oehansen.pp.se
                                          oehansen@daimi.aau.dk
                                        voice+fax; +46 035 217194

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: multiple definitions of....
  1997-12-10 10:58 ` Jason Merrill
@ 1997-12-11  6:54   ` Orn E. Hansen
  0 siblings, 0 replies; 3+ messages in thread
From: Orn E. Hansen @ 1997-12-11  6:54 UTC (permalink / raw)
  To: egcs

[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #1: Type: text/plain, Size: 2684 bytes --]

Jason Merrill writes:
 > >>>>> Orn E Hansen <oe.hansen@oehansen.pp.se> writes:
 > 
 > >   As was reported yesterday, the new snapshot has a problem with strings.
 > > Now, it isn't difficult to compile bastring.cc as a template class, and
 > > include it, but in a program I get this additional error
 > 
 > We'll need a testcase if we're going to fix this.
 > 

 Well, I tried using bastring.cc, bastring.h and stlinst.cc from 1201
snapshot, and then recompiling.  Doing this got rid of the first
reported error messages, but the *alloc_template<false,0> message were 
now reversed to *alloc_template<true,0>, and these were now missing,
not multiple redefinitions.

  Following this I reversed the 01-07 diffs.  Returning the sources
back to the 1201 snapshot and then did "make" again.  This, I figured,
would rebuild the libraries, which it did... but the errors remained.
I needed to bootstrap the compiler, and after this the reverseing to
1201 snapshot worked fine.  As far as I can understand from the above, 
this looks like a problem with the linker, and not the library itself
(I guess this is the difference between doing a "make" and "make
bootstrap", the latter builds a temporary "xgcc" to build the compiler 
and libraries, while the former only updates what has changed?

 To try and use strings with 1207 snapshot, I made a small string
template class...

---- strings.C

#include <std/bastring.cc>

template class basic_string<char>;

----

 and tested it with...

---- str.C
#include <iostream.h>
#include <string>

main()
{
  string str;

  str = "Halló heimur";
  cout << str.c_str() << endl;
  str += "þarna úti!";
  cout << str.c_str() << endl;
}
----

Compiling...

g++ -c strings.C
g++ str.C strings.o -o str

is OK.

and running, gives correct output.  However, if you split a mainfile
into parts.  I have an application split into several object files,
each uses string.  Basically this would look like (a representation of 
the abstract application used to get the error).

---- str1.h
#include <iostream.h>
#include <string>

class error {
public:
  error();
  ~error();

  void anError();
};

---- str1.C
#include "str1.h"

error::error()
{
}

error::~error()
{
}

void error::anError()
{
  string t;

  t = "String is now in two files";
  cout << t.c_str() << endl;
}

---- str2.C
#include <iostream.h>
#include <string>

#include <str1.h>

main()
{
  error foo;
  string s;

  s = "Halló heimur";
  cout << s.c_str() << endl;
  foo.anError();
}
----

and compiling...

g++ -c strings.C
g++ -c str1.C
g++ -c str2.C
g++ str2.o str1.o strings.o -o str

results in the reporting of multiple definitions of
  __default_alloc_template<false,0>


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: multiple definitions of....
       [not found] <XFMail.971210123242.oe.hansen.cygnus.egcs@oehansen.pp.se>
@ 1997-12-10 10:58 ` Jason Merrill
  1997-12-11  6:54   ` Orn E. Hansen
  0 siblings, 1 reply; 3+ messages in thread
From: Jason Merrill @ 1997-12-10 10:58 UTC (permalink / raw)
  To: egcs

>>>>> Orn E Hansen <oe.hansen@oehansen.pp.se> writes:

>   As was reported yesterday, the new snapshot has a problem with strings.
> Now, it isn't difficult to compile bastring.cc as a template class, and
> include it, but in a program I get this additional error

We'll need a testcase if we're going to fix this.

Jason

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~1997-12-11  6:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1997-12-10  3:46 multiple definitions of Orn E. Hansen
     [not found] <XFMail.971210123242.oe.hansen.cygnus.egcs@oehansen.pp.se>
1997-12-10 10:58 ` Jason Merrill
1997-12-11  6:54   ` Orn E. Hansen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).