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?
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With