Error on Linux: "cannot find source code for runtime library file 'object.d' "

Jonathan M Davis jmdavisProg at gmx.com
Fri Mar 1 11:12:02 PST 2013


On Friday, March 01, 2013 18:29:53 Vectrum wrote:
> I've just started using D but, unfortunately I
> got an error while compiling the following
> D code;
> 
> import std.stdio;
> main()
> {
> writefln("%sHello, World!");
> }
> 
> It gives me the following error;
> 
> $ dmd hello.d
> Error: cannot find source code for runtime library file 'object.d'
> dmd might not be correctly installed. Run 'dmd -man' for
> installation instructions.
> import path[0] = /usr/local/src/phobos
> 
> I installed D twice, used a shell-script second time when
> got the error but so phobos copied to two locations and
> dmd.conf has been changed accordingly.
> 
> [Environment]
> DFLAGS=-I/usr/local/include/d/phobos2 -L-L/usr/local/lib
> DFLAGS=-I/usr/local/src/phobos -L-L/usr/local/lib
> 
> Plase tell me what is the correct location for the lib and
> standard .d files.
> I'm getting very frustrated and none bothers to address
> the issue. I hope I haven't made a silly mistake.

The correct one is pretty much wherever you want to put them. It's just that 
you have to put it in dmd.conf. As to your problem, I see three issues right 
off the bat:

1. You're resetting DFLAGS, not appending to it. Notice that the only import 
path listed in your error is the second one. The first one got overwritten. I'd 
suggest just putting it all on one line.

2. I don't know why you're listing two locations for Phobos anyway. You need
a -I to point to where the Phobos src is located, and there's only one set. -I 
needs to point to whatever directory std and etc are in order for the compiler 
to find Phobos.

3. You're missing druntime's import files (hence the error, since that's where 
object.di is). So, you need a -I flag pointing to druntime's import directory.

However, if you're not going to use your package manager to install dmd, I'd 
suggest that you just download the zip file, unzip it somewhere on your box, 
and add its linux/bin directory to your PATH. If you do that, it should all 
just work.

- Jonathan M Davis


More information about the Digitalmars-d mailing list