简体   繁体   中英

Erlang compiler cannot find include file test.hrl

I am having a project where suppose:

Project structure is root/p1/mod1/include/test.hrl and root/p2/mod2/foo.erl I have a erlang hrl file in root/p1/mod1/include and i have included it in erlang file (.erl) in root/p2/mod2

When I am compiling file foo.erl it gives following error:

foo.erl:16: can't find include file "test.hrl"

I tried including it in -I flag of erlc such as below:

user[root/p2/mod2]$ erlc foo.erl -I "/local/user/root/p1/mod1/include"
foo.erl:16: can't find include file "test.hrl"

But it does not seem to solve it. Can anyone help on how to resolve it?

In Erlang , the command should be below:

erlc flags file1.ext file2.ext...

Compiles one or more files. The files must include the extension, for example, .erl for Erlang source code, or .yrl for Yecc source code. Erlc uses the extension to invoke the correct compiler

The following flags are supported:

-I 'Directory'

So just move your -I before erl file:

erlc -I "/local/user/root/p1/mod1/include" foo.erl

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM