-include_lib не находит мою библиотеку
Я создал такой проект:
$> 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
Теперь я хочу включить foo.hrl в barlib.erl
:
-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)
а также code:lib_dir(bar)
Это выглядит хорошо для меня:
$> 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 не работает?
ТИА
1 ответ
Решение
Делает приложение bar
зависит от приложения foo
в его application
кортеж в своем.app-файле? Это обычно требуется, чтобы заставить вещи работать.