www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - GDC and Tango problem

reply revcompgeek <revcompgeek gmail.com> writes:
So I tried building Tango trunk a while ago, and it actually built
surprisingly well, with only one small error I was able to fix. So I
installed the tango library and proceeded to test if tango was really
working. So in hello.d:

import tango.io.Stdout;
void main(){ Stdout("Hello {}!","World").newline; }

I don't know why, but I had to manually add object.d to the command
line. To simplify, I put an object file of object.d into the current
directory.

tests% gdc -o hello hello.d object.o -lgtango -lgphobos
ld: duplicate symbol __D6object9Interface6__initZ in
/usr/local/lib/libgphobos.a(object.o) and object.o
collect2: ld returned 1 exit status

I'm not sure if this problem is an issue with gdc or a problem with
Tango. Any ideas on how to fix this?
Dec 28 2009
parent reply grauzone <none example.net> writes:
revcompgeek wrote:
 
 So I tried building Tango trunk a while ago, and it actually built
 surprisingly well, with only one small error I was able to fix. So I
 installed the tango library and proceeded to test if tango was really
 working. So in hello.d:
 
 import tango.io.Stdout;
 void main(){ Stdout("Hello {}!","World").newline; }
 
 I don't know why, but I had to manually add object.d to the command
 line. To simplify, I put an object file of object.d into the current
 directory.
 
 tests% gdc -o hello hello.d object.o -lgtango -lgphobos
 ld: duplicate symbol __D6object9Interface6__initZ in
 /usr/local/lib/libgphobos.a(object.o) and object.o
 collect2: ld returned 1 exit status
 
 I'm not sure if this problem is an issue with gdc or a problem with
 Tango. Any ideas on how to fix this?
You're linking with both Phobos and Tango. You can't do that, because both come with their own (incompatible) runtime. Removing the "-lgphobos" should work.
Dec 29 2009
parent reply "Steven Schveighoffer" <schveiguy yahoo.com> writes:
On Tue, 29 Dec 2009 16:34:20 -0500, grauzone <none example.net> wrote:

 revcompgeek wrote:
  So I tried building Tango trunk a while ago, and it actually built
 surprisingly well, with only one small error I was able to fix. So I
 installed the tango library and proceeded to test if tango was really
 working. So in hello.d:
  import tango.io.Stdout;
 void main(){ Stdout("Hello {}!","World").newline; }
  I don't know why, but I had to manually add object.d to the command
 line. To simplify, I put an object file of object.d into the current
 directory.
  tests% gdc -o hello hello.d object.o -lgtango -lgphobos
 ld: duplicate symbol __D6object9Interface6__initZ in
 /usr/local/lib/libgphobos.a(object.o) and object.o
 collect2: ld returned 1 exit status
  I'm not sure if this problem is an issue with gdc or a problem with
 Tango. Any ideas on how to fix this?
You're linking with both Phobos and Tango. You can't do that, because both come with their own (incompatible) runtime. Removing the "-lgphobos" should work.
I think you need -lgphobos. Last time gdc was updated, the compiler called the runtime gphobos, even though it was just the runtime :) Even with dmd, tango needed to call the runtime libphobos to get it to link because the name was hard-coded in the compiler. Subsequent versions of dmd allowed changing the runtime library name. I don't know if gdc was updated to do the same. I think the problem is adding object.d to the command line, you should not have to do that. The user is probably missing object.di. I'm not sure how well the latest tango works with gdc. It's probably better to ask on the tango forums (http://www.dsource.org/projects/tango/forums). -Steve
Dec 29 2009
parent revcompgeek <revcompgeek gmail.com> writes:
On 12/29/09 2:41 PM, Steven Schveighoffer wrote:
 On Tue, 29 Dec 2009 16:34:20 -0500, grauzone <none example.net> wrote:

 revcompgeek wrote:
 So I tried building Tango trunk a while ago, and it actually built
 surprisingly well, with only one small error I was able to fix. So I
 installed the tango library and proceeded to test if tango was really
 working. So in hello.d:
 import tango.io.Stdout;
 void main(){ Stdout("Hello {}!","World").newline; }
 I don't know why, but I had to manually add object.d to the command
 line. To simplify, I put an object file of object.d into the current
 directory.
 tests% gdc -o hello hello.d object.o -lgtango -lgphobos
 ld: duplicate symbol __D6object9Interface6__initZ in
 /usr/local/lib/libgphobos.a(object.o) and object.o
 collect2: ld returned 1 exit status
 I'm not sure if this problem is an issue with gdc or a problem with
 Tango. Any ideas on how to fix this?
You're linking with both Phobos and Tango. You can't do that, because both come with their own (incompatible) runtime. Removing the "-lgphobos" should work.
I think you need -lgphobos. Last time gdc was updated, the compiler called the runtime gphobos, even though it was just the runtime :) Even with dmd, tango needed to call the runtime libphobos to get it to link because the name was hard-coded in the compiler. Subsequent versions of dmd allowed changing the runtime library name. I don't know if gdc was updated to do the same. I think the problem is adding object.d to the command line, you should not have to do that. The user is probably missing object.di. I'm not sure how well the latest tango works with gdc. It's probably better to ask on the tango forums (http://www.dsource.org/projects/tango/forums). -Steve
If I don't add object.d to the command line, I get a ton more missing symbols. I had also originally tried replacing libgphobos.a with libgtango.a, but that didn't work either. I will try posting to the forums, thanks.
Dec 29 2009