# Interconnected Modules

**URL:** <https://discourse.julialang.org/t/interconnected-modules/13546>\
**Category:** New to Julia\
**Created:** [August 16, 2018, 3:50am UTC](https://discourse.julialang.org/t/interconnected-modules/13546 "2018-08-16T03:50:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![slakeon](https://avatars.discourse-cdn.com/v4/letter/s/e274bd/32.png) [@slakeon](https://discourse.julialang.org/u/slakeon)\
**Post date:** [August 16, 2018, 3:50am UTC](https://discourse.julialang.org/t/interconnected-modules/13546/1 "2018-08-16T03:50:12Z")

</div>

I have three modules: A, B and C. Module C uses functions from A and B. However, when I try to load modules A, B and C and I try to use a function from C that employs functions from A or B, an error says that functions from A or B are not available.

I included `import A: function1, function 2, ..." and `import B: function3, function 4, …" in module C.

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [August 16, 2018, 5:43am UTC](https://discourse.julialang.org/t/interconnected-modules/13546/2 "2018-08-16T05:43:10Z")

</div>

Which version are you on (check with `versioninfo()`)?

In 0.7/1.0 you’ll have to `pkg> activate <path/to/ module>` the modules environment and `pkg> add <dependency>` before it can be used in the module.

---

<div class="post-metadata">

**Author:** ![migarstka](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/migarstka/32/3828_2.png) [@migarstka](https://discourse.julialang.org/u/migarstka)\
**Post date:** [August 16, 2018, 11:01am UTC](https://discourse.julialang.org/t/interconnected-modules/13546/3 "2018-08-16T11:01:52Z")

</div>

An example that should work in the REPL with Julia 1.0:

```julia
# define modules
module modA
  export double

  function double(x)
    return 2*x
  end

end

module modB

  function timesThree(x)
    return 3*x
  end

end

module modC
  using Main.modA
  export combineFunctions

  function combineFunctions(x)
    x = double(x)
    x = Main.modB.timesThree(x)
    return x
  end

end

# use modules
using .modC, Test

x = 10.

x = combineFunctions(x)
@test x == 60.

```

---

<div class="post-metadata">

**Author:** ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)\
**Post date:** [August 16, 2018, 11:12am UTC](https://discourse.julialang.org/t/interconnected-modules/13546/4 "2018-08-16T11:12:23Z")

</div>

The REPL is a different beast, since it knows all about modules defined in itself. The problem only exists when creating a module as a package and trying to import other packages. Those need to be `add`ed in order for the environment of the other package to know about.
