# Embedding and include

**URL:** <https://discourse.julialang.org/t/embedding-and-include/13524>\
**Category:** General Usage\
**Tags:** embedding\
**Created:** [August 15, 2018, 8:30pm UTC](https://discourse.julialang.org/t/embedding-and-include/13524 "2018-08-15T20:30:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [August 15, 2018, 8:30pm UTC](https://discourse.julialang.org/t/embedding-and-include/13524/1 "2018-08-15T20:30:01Z")

</div>

What is the story with `include` in embedded Julia on 0.7+? If, for example, you add

```julia
        checked_eval_string("include(\"LocalModule.jl\")");

```

in the embedding example (`test/embedding/embedding.c`), the result is

```julia
UndefVarError: include not defined

```

To be able to include something you need to do `Base.include(Main, filename)` instead or start out with an eval of `include(x) = Base.include(Main, x)`. Is this a feature or a bug? If it’s intentional I think it needs some kind of mention in the documentation.

---

<div class="post-metadata">

**Author:** ![mikeando](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@mikeando](https://discourse.julialang.org/u/mikeando)\
**Post date:** [September 25, 2018, 1:47pm UTC](https://discourse.julialang.org/t/embedding-and-include/13524/2 "2018-09-25T13:47:23Z")

</div>

I also would love an explanation for this. I’ve just spent all morning banging my head against working out that a failure to include some code was causing all my errors. Your work around has at least got me progressing further.

As an aside I’d love to see your definition of `checked_eval_string` - I’ve got a really rough one myself that could do with a clean up.

---

<div class="post-metadata">

**Author:** ![GunnarFarneback](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/gunnarfarneback/32/1827_2.png) [@GunnarFarneback](https://discourse.julialang.org/u/GunnarFarneback)\
**Post date:** [September 25, 2018, 2:02pm UTC](https://discourse.julialang.org/t/embedding-and-include/13524/3 "2018-09-25T14:02:40Z")

</div>

I was referring to `checked_eval_string` in the embedding example in Julia’s source code: [https://github.com/JuliaLang/julia/blob/master/test/embedding/embedding.c#L17-L31](https://github.com/JuliaLang/julia/blob/master/test/embedding/embedding.c#L17-L31)

Depending on how you do your embedding you might find things of interest in some of these issues and a PR:  
[https://github.com/JuliaLang/julia/issues/28820](https://github.com/JuliaLang/julia/issues/28820)  
[https://github.com/JuliaLang/julia/issues/28824](https://github.com/JuliaLang/julia/issues/28824)  
[https://github.com/JuliaLang/julia/issues/28825](https://github.com/JuliaLang/julia/issues/28825)  
[https://github.com/JuliaLang/julia/issues/28826](https://github.com/JuliaLang/julia/issues/28826)  
[https://github.com/JuliaLang/julia/pull/28886](https://github.com/JuliaLang/julia/pull/28886)

---

<div class="post-metadata">

**Author:** ![mikeando](https://avatars.discourse-cdn.com/v4/letter/m/f08c70/32.png) [@mikeando](https://discourse.julialang.org/u/mikeando)\
**Post date:** [September 25, 2018, 11:31pm UTC](https://discourse.julialang.org/t/embedding-and-include/13524/4 "2018-09-25T23:31:48Z")

</div>

Those are great references, and should help,

Thanks.
