“模块x在x.d中无法读取”。编译d程序时出错 [英] "Module x is in x.d which cannot be read" error when compiling a d program

查看:151
本文介绍了“模块x在x.d中无法读取”。编译d程序时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是项目结构:

.
├── 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的内容:

Content of 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.

关于出什么问题了吗?谢谢。

Any ideas about what went wrong? Thanks.

推荐答案

好的,我的错,我忘记在 dub.json 中指定依赖项了code>,应为:

Ok, my fault, I forgot to specify the dependency in dub.json, it should be:

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

下次我看到这种错误时,我会谨记在那儿。

Next time I see this kind of error, I will remeber to look there.

这篇关于“模块x在x.d中无法读取”。编译d程序时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆