why
why

Reputation: 24851

How to call the module which is not in the same folder in Erlang?

I am learning one opensource project, the homepage is here: https://github.com/kevsmith/gen_nb_server , I found that the project structure is

src/
  gen_nb_server.erl
priv/
  example
    src/
      example.erl

when I am going into example folder and run "make", and run the example module by "example:start_link().", it can not find gen_nb_server module, I want to know how to call the module which does not be laid in the same folder ? thanks!

Upvotes: 1

Views: 329

Answers (2)

arun_suresh
arun_suresh

Reputation: 2925

In addition to what butter71 mentioned.. you can load code while in the shell itself...

1> code:add_path("gen_nb_server/ebin").

you can also use code:add_patha or code:add_pathz to load the beam files at the beginning or end of path list..

Upvotes: 3

butter71
butter71

Reputation: 2723

You can use -pa (or -pz) to add the top-level ebin and priv/example/ebin directories to the front (or end) of your code path.

# erl -pa gen_nb_server/ebin -pa gen_nb_server/priv/example/ebin
[...]
1> example:start_link().
{ok,<0.33.0>}

Upvotes: 5

Related Questions