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

2

12

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?

Regimentals answered 28/8, 2010 at 22:44 Comment(2)
Please post the output of compiling with dmd -v.Tangled
C:\hope\D>dmd tcpechoserver.d -v parse tcpechoserver importall tcpechoserver import object (C:\D\bin\..\import\object.di) import std.stdio (std\stdio.d) tcpechoserver.d(3): Error: module stdio cannot read file 'std\stdio.d'Regimentals
B
5

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.

Bargainbasement answered 29/8, 2010 at 8:28 Comment(0)
B
8

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.

Bluecollar answered 29/8, 2010 at 9:57 Comment(0)
B
5

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.

Bargainbasement answered 29/8, 2010 at 8:28 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.