Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

D programming language: module stdio cannot read file std\stdio.d

Tags:

d

dmd

I installed dmd (2.0 ?) using the windows installer and am trying to compile the following program:

module tcpechoserver;

import std.stdio;

const int MAXPENDING = 5;

int main(char[][] argv)
{
    if(argv.length != 2){
        writef("Usage: %s <port>", argv[0]);
    }

    return 0;
}   

But I get the following compiler error:

Error: module stdio cannot read file 'std\stdio.d'

Are there some paths I have to specify in order to get the standard library to work?

like image 760
lowerkey Avatar asked Aug 28 '10 22:08

lowerkey


2 Answers

When you get errors like that, it means that DMD cannot find the import file. If you import foo.bar.xyz, then it expects it to find a xyz.d in some directory foo\bar\.

It searches for this directory in all its standard import paths, as well as the current directory (for example, if you added a directory std next to your tcpechoserver.d with a stdio.d in it, then it would use that). Of course, you don't want that -- you want the standard stdio.d.

You can find what directories it looks it by opening the file

C:\D\dmd2\windows\bin\sc.ini (assuming you installed to the default directory).

Inside that, it should contain the line:

DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src\druntime\import"

which is telling the compiler to search those paths when looking for import directories. If you don't have that line for whatever reason (or if the line is different) then try adding this line into sc.ini (anywhere under the [Environment] header should do.

Also ensure that the dmd2 directory contains a \src\phobos\std\stdio.d file.

If both these don't work, then I'd recommend reinstalling from scratch.

like image 62
Peter Alexander Avatar answered Jan 16 '23 00:01

Peter Alexander


Look at the ~\windows\bin\sc.ini file in your dmd installation directory. It contains implicit command line arguments for dmd, which should look as this for dmd 2.048:

LIB="%@P%\..\lib";\dm\lib

and

DFLAGS="-I%@P%\..\..\src\phobos" "-I%@P%\..\..\src\druntime\import"

If they are ok, and it doesn't works, your installation is probably broken. I recommend you to simply download zipped version of compiler and unpack it over your installation.

like image 40
Michal Minich Avatar answered Jan 15 '23 23:01

Michal Minich