gpt4 book ai didi

erlang - -include_lib 找不到我的库

转载 作者:行者123 更新时间:2023-12-03 12:12:31 25 4
gpt4 key购买 nike

我创建了这样一个项目:

$> rebar3 new release foo
$> cd foo
$> rebar3 new app bar

结构如下:

$> tree foo

|-- _build
| `-- default
|-- _checkouts
| |-- bar -> ../bar
| `-- rebar.lock
|-- apps
| `-- foo
| |-- include
| | `-- foo.hrl
| `-- src
| |-- foo.app.src
| |-- foo_app.erl
| `-- foo_sup.erl
|
|-- bar
| `-- src
| |-- bar.app.src
| |-- bar_app.erl
| |-- bar_sup.erl
| `-- barlib.erl
|-- config
| |-- sys.config
| `-- vm.args
|-- rebar.config
`-- rebar.lock

现在我想在 barlib.erl 中包含 foo.hrl:

-module(barlib).

%% API
-export([foo/0]).
-include_lib("foo/include/foo.hrl").


foo()->
ok.

编译给出:

$> rebar3 compile
===> Verifying dependencies...
===> Compiling bar
===> Compiling _checkouts/bar/src/barlib.erl failed
_checkouts/bar/src/barlib.erl:5: can't find include lib "foo/include/foo.hrl"

当我删除 -include_lib 指令并调用 rebar3 shell 时,我可以检索 code:lib_dir(foo)代码: lib_dir(栏)

这对我来说很好:

$> rebar3 shell
===> Verifying dependencies...
===> Compiling bar
===> Compiling foo
Eshell V9.3 (abort with ^G)
1> ===> The rebar3 shell is a development tool; to deploy applications in production, consider using releases (http://www.rebar3.org/docs/releases)
1> ===> Booted bar
1> ===> Booted foo
1> ===> Booted sasl
1>
=PROGRESS REPORT==== 26-Jul-2018::22:07:44 ===
supervisor: {local,sasl_safe_sup}
started: [{pid,<0.139.0>},
{id,alarm_handler},
{mfargs,{alarm_handler,start_link,[]}},
{restart_type,permanent},
{shutdown,2000},
{child_type,worker}]
1> 1>
=PROGRESS REPORT==== 26-Jul-2018::22:07:44 ===
supervisor: {local,sasl_sup}
started: [{pid,<0.138.0>},
{id,sasl_safe_sup},
{mfargs,
{supervisor,start_link,
[{local,sasl_safe_sup},sasl,safe]}},
{restart_type,permanent},
{shutdown,infinity},
{child_type,supervisor}]
1> 1>
=PROGRESS REPORT==== 26-Jul-2018::22:07:44 ===
supervisor: {local,sasl_sup}
started: [{pid,<0.140.0>},
{id,release_handler},
{mfargs,{release_handler,start_link,[]}},
{restart_type,permanent},
{shutdown,2000},
{child_type,worker}]
1> 1>
=PROGRESS REPORT==== 26-Jul-2018::22:07:44 ===
application: sasl
started_at: nonode@nohost
2> code:lib_dir(foo).
"/usr/home/xxxx/foo/_build/default/lib/foo"
3> code:lib_dir(bar).
"/usr/home/xxxx/foo/_checkouts/bar"
4>

那么,为什么 include_lib 不起作用?

TIA

最佳答案

app bar 是否依赖于其 .app 文件中 application 元组中的 app foo?这通常是使事情正常运行所必需的。

关于erlang - -include_lib 找不到我的库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51546948/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com