www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Linking fails on Hello World?!

reply qwesx <noreply mydomain.org> writes:
Hello!

I just installed LDC on Debian from the repository and tried out to compile a
simple Hello World program:
 import tango.io.Stdout;
 int main(char[][] argv) {
   Stdout("Hello world!");
   return 0;
 }
Looks simlpe enough, but when running "ldc main.d" the following error is printed:
 main.o: In function `_Dmain':
 main:(.text+0x2a): undefined reference to
`_D5tango2io6Stdout6StdoutC5tango2io6stream6Format20__T12FormatOutputTaZ12FormatOutput'
 main:(.text+0x41): undefined reference to
`_D5tango2io6stream6Format20__T12FormatOutputTaZ12FormatOutput5printMFYC5tango2io6stream6Format20__T12FormatOutputTaZ12FormatOutput'
 main.o:(.rodata+0x18): undefined reference to `_D5tango2io6Stdout8__ModuleZ'
collect2: ld returned 1 exit status
 Error: linking failed:
 status: 1
The files /usr/include/d/tango/io/Stdout.d, /usr/lib/d/libtango-base-ldc.a and /usr/lib/d/libtango-user-ldc.a exist and are readable. I don't know if that's important though. What's wrong here? Is it my fault? How can I fix it? Thanks for your time :)
Mar 25 2010
parent reply Robert Clipsham <robert octarineparrot.com> writes:
On 25/03/10 15:02, qwesx wrote:
 Hello!

 I just installed LDC on Debian from the repository and tried out to compile a
simple Hello World program:
 import tango.io.Stdout;
 int main(char[][] argv) {
    Stdout("Hello world!");
    return 0;
 }
Looks simlpe enough, but when running "ldc main.d" the following error is printed:
 main.o: In function `_Dmain':
 main:(.text+0x2a): undefined reference to
`_D5tango2io6Stdout6StdoutC5tango2io6stream6Format20__T12FormatOutputTaZ12FormatOutput'
 main:(.text+0x41): undefined reference to
`_D5tango2io6stream6Format20__T12FormatOutputTaZ12FormatOutput5printMFYC5tango2io6stream6Format20__T12FormatOutputTaZ12FormatOutput'
 main.o:(.rodata+0x18): undefined reference to `_D5tango2io6Stdout8__ModuleZ'
collect2: ld returned 1 exit status
 Error: linking failed:
 status: 1
The files /usr/include/d/tango/io/Stdout.d, /usr/lib/d/libtango-base-ldc.a and /usr/lib/d/libtango-user-ldc.a exist and are readable. I don't know if that's important though. What's wrong here? Is it my fault? How can I fix it? Thanks for your time :)
Try this: $ ldc -L-L/usr/lib/d -L-ltango-base-ldc -L-ltango-user-ldc main.d If that works you need to make sure these -L's are included in yout ldc.conf (I'm not sure where this is in the debian packages, probably /etc/ldc.conf, /etc/ldc/ldc.conf or /usr/bin/ldc.conf).
Mar 25 2010
parent reply qwesx <noreply mydomain.org> writes:
Robert Clipsham Wrote:

 Try this:
 $ ldc -L-L/usr/lib/d -L-ltango-base-ldc -L-ltango-user-ldc main.d
 
 If that works you need to make sure these -L's are included in yout 
 ldc.conf (I'm not sure where this is in the debian packages, probably 
 /etc/ldc.conf, /etc/ldc/ldc.conf or /usr/bin/ldc.conf).
Thank you very much, it works now. -L-L/usr/lib/d and -L-ltango-base-ldc were already in the /etc/ldc.conf, but -L-ltango-user-ldc was missing. As I am pretty new to D, is it reasonable that this line was missing or is it worth a bug-report? Thank you very much!
Mar 25 2010
next sibling parent Robert Clipsham <robert octarineparrot.com> writes:
On 25/03/10 15:34, qwesx wrote:
 Robert Clipsham Wrote:

 Try this:
 $ ldc -L-L/usr/lib/d -L-ltango-base-ldc -L-ltango-user-ldc main.d

 If that works you need to make sure these -L's are included in yout
 ldc.conf (I'm not sure where this is in the debian packages, probably
 /etc/ldc.conf, /etc/ldc/ldc.conf or /usr/bin/ldc.conf).
Thank you very much, it works now. -L-L/usr/lib/d and -L-ltango-base-ldc were already in the /etc/ldc.conf, but -L-ltango-user-ldc was missing. As I am pretty new to D, is it reasonable that this line was missing or is it worth a bug-report? Thank you very much!
The line won't be in there by default, as the tango user library isn't required to write your applications, only the runtime is. If you'd like to report a bug it should be to the packagers to see if they can automatically add in the user library to the configuration file when you install it. I'll add a note to http://dsource.org/projects/ldc/wiki/BuildInstructionsUbuntu for future users in case anyone else has the problem.
Mar 25 2010
prev sibling parent Moritz Warning <moritzwarning web.de> writes:
On Thu, 25 Mar 2010 11:34:15 -0400, qwesx wrote:

 Robert Clipsham Wrote:
 
 Try this:
 $ ldc -L-L/usr/lib/d -L-ltango-base-ldc -L-ltango-user-ldc main.d
 
 If that works you need to make sure these -L's are included in yout
 ldc.conf (I'm not sure where this is in the debian packages, probably
 /etc/ldc.conf, /etc/ldc/ldc.conf or /usr/bin/ldc.conf).
Thank you very much, it works now. -L-L/usr/lib/d and -L-ltango-base-ldc were already in the /etc/ldc.conf, but -L-ltango-user-ldc was missing. As I am pretty new to D, is it reasonable that this line was missing or is it worth a bug-report? Thank you very much!
Hi, I've found the bug yesterday and wrote to ldc packages.debian.org already.
Mar 25 2010