“模块x是XD,其不能被读”编译广告节目时错误(“Module x is in x.d which

2019-10-21 11:12发布

下面是项目结构:

.
├── dub.json
├── dub.selections.json
├── dub.userprefs
├── source
│   └── app.d
└── testd2

内容app.d

import std.stdio;
import scid.matrix;
import colorize: fg, color, cwriteln, cwritefln;


void main()
{
    cwriteln("This is blue.".color(fg.blue));
    auto c = "red";
    cwritefln("This is %s".color(c), c);
}

dub.josn的内容:

{
    "name": "testd2",
    "description": "A minimal D application.",
    "copyright": "Copyright © 2014, kaiyin",
    "authors": ["kaiyin"],
    "dependencies": {
        "colorize": ">=1.0.5"
    }
}

生成错误:

dub build
Building colorize 1.0.5 configuration "library", build type debug.
Running dmd...
Building testd2 ~master configuration "application", build type debug.
Compiling using dmd...
source/app.d(2): Error: module matrix is in file 'scid/matrix.d' which cannot be read
import path[0] = source/
import path[1] = ../../../.dub/packages/colorize-1.0.5/source
import path[2] = /usr/local/Cellar/dmd/2.066.0/include/d2
FAIL .dub/build/application-debug-posix.osx-x86_64-dmd_2066-1DB186F012CD3E69677DBEA746FFBDE1/ testd2 executable
Error executing command build: dmd failed with exit code 1.

什么任何想法出了问题? 谢谢。

Answer 1:

好吧,我的错,我忘了指定的依赖dub.json ,它应该是:

{
    "name": "testd2",
    "description": "A minimal D application.",
    "copyright": "Copyright © 2014, kaiyin",
    "authors": ["kaiyin"],
    "dependencies": {
        "colorize": ">=1.0.5",
        "scid": ">=0.1.0"
    }
}

下一次,我看到这样那样的错误,我会remeber到那里寻找。



文章来源: “Module x is in x.d which cannot be read” error when compiling a d program
标签: d