Linking fails on Hello World?!

Robert Clipsham robert at octarineparrot.com
Thu Mar 25 08:25:32 PDT 2010


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).



More information about the Digitalmars-d mailing list