# Embedding: Ubuntu PPA library location

**URL:** <https://discourse.julialang.org/t/embedding-ubuntu-ppa-library-location/3270>\
**Category:** General Usage\
**Tags:** embedding, linux\
**Created:** [April 18, 2017, 5:45pm UTC](https://discourse.julialang.org/t/embedding-ubuntu-ppa-library-location/3270 "2017-04-18T17:45:58Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![SylvainCorlay](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaincorlay/32/923_2.png) [@SylvainCorlay](https://discourse.julialang.org/u/SylvainCorlay)\
**Post date:** [April 18, 2017, 5:45pm UTC](https://discourse.julialang.org/t/embedding-ubuntu-ppa-library-location/3270/1 "2017-04-18T17:45:58Z")

</div>

I am working on embedding the Julia interpreter as a library in a C++ application (in the context of testing julia bindings for a library).

At the moment, I doing experiments with the build from the ubuntu PPA [https://launchpad.net/~staticfloat/+archive/ubuntu/juliareleases](https://launchpad.net/~staticfloat/+archive/ubuntu/juliareleases) by @staticfloat.

While the libjulia.so library is found in `/usr/lib/x86_64-linux-gnu/` as expected, a number of other shared libraries required by `libjulia.so` are installed into `/usr/lib/x86_64-linux-gnu/julia`.

`ldd` gives

```julia
linux-vdso.so.1 => (0x00007ffc7dbf5000)
libLLVM-3.7.1.so => /usr/lib/x86_64-linux-gnu/julia/libLLVM-3.7.1.so (0x00007f5641ca3000)
libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5641a7f000)
librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f5641876000)
libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5641659000)
libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f56412d7000)
libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5640fcd000)
libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f5640db7000)
libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f56409ee000)
/lib64/ld-linux-x86-64.so.2 (0x000055fca1548000)
libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f56407d3000)

```

So I need to add custom link directories with the cmake `link_directories` function.

I am wondering what is the proper way to deal with these extra shared libraries. The `FindJulia.cmake` that I am using is [https://github.com/SylvainCorlay/xtensor-julia/blob/cpp-tests/deps/test/FindJulia.cmake](https://github.com/SylvainCorlay/xtensor-julia/blob/cpp-tests/deps/test/FindJulia.cmake)

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [April 19, 2017, 2:27pm UTC](https://discourse.julialang.org/t/embedding-ubuntu-ppa-library-location/3270/2 "2017-04-19T14:27:46Z")

</div>

There is a script in contrib called `julia-config.jl` which should print out the necessary flags, but it does not appear to do so correctly in the PPA version of 0.5.

I would suggest doing any new embedding development work against the 0.6-beta nightly, because we recently made [a number of improvements](https://github.com/JuliaLang/julia/pull/21299) to the embedding API and Makefile. The following examples are from the latest generic nightly:

- the `ldlibs` flag:

```julia
osboxes@osboxes:~/Downloads/julia-085876ee90$ bin/julia share/julia/julia-config.jl --ldlibs
  
  -Wl,-rpath,/home/osboxes/Downloads/julia-085876ee90/lib
  -Wl,rpath,/home/osboxes/Downloads/julia-085876ee90/bin/../lib/julia
  -ljulia

```

- the example `Makefile` now requires only the path to `julia` and the output binary directory (no dependency on the rest of the Julia build system):

```julia
osboxes@osboxes:~/Downloads/julia-085876ee90/share/doc/julia/examples/embedding$ make JULIA=~/Downloads/julia-085876ee90/bin/julia BIN=./

cc /home/osboxes/Downloads/julia-085876ee90/share/doc/julia/examples/embedding/embedding.c -o embedding -lm -std=gnu99 -DJULIA_ENABLE_THREADING=1 -fPIC -DJULIA_INIT_DIR=\"/home/osboxes/Downloads/julia-085876ee90/lib\" -I/home/osboxes/Downloads/julia-085876ee90/include/julia -L/home/osboxes/Downloads/julia-085876ee90/lib -Wl,--export-dynamic -Wl,-rpath,/home/osboxes/Downloads/julia-085876ee90/lib -Wl,-rpath,/home/osboxes/Downloads/julia-085876ee90/bin/../lib/julia -ljulia

```

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [April 19, 2017, 2:29pm UTC](https://discourse.julialang.org/t/embedding-ubuntu-ppa-library-location/3270/3 "2017-04-19T14:29:39Z")

</div>

Also, note that the only libraries you should need to worry about are `libLLVM` and `libjulia`. The rest of those are system libraries. We distribute a separate `libLLVM` in the PPA because either the distro version is too old, or we require patched LLVM (often both).

---

<div class="post-metadata">

**Author:** ![SylvainCorlay](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaincorlay/32/923_2.png) [@SylvainCorlay](https://discourse.julialang.org/u/SylvainCorlay)\
**Post date:** [April 19, 2017, 2:49pm UTC](https://discourse.julialang.org/t/embedding-ubuntu-ppa-library-location/3270/4 "2017-04-19T14:49:41Z")

</div>

@ihnorton thanks for your response.

Since I am using cmake, I would rather not pass compilation flags directly. I found a way around the issue described earlier. Since julia does not provide a `JuliaConfig.cmake` and `JuliaConfigVersion.cmake`, I put together a `FindJulia.cmake` which interogates julia for its library and include directories, as well as the value that I should use for `JULIA_HOME` …

The only remaining ad-hoc thing in my cmake is

```julia
find_library(LIBLLVM libLLVM libLLVM-3.7.1.so HINTS ${Julia_LIBRARY_DIR}/julia)

```

which directly requires knowing the full version string of libLLVM. If there was a cleaner way to retrieve this, it would be fantastic.

---

<div class="post-metadata">

**Author:** ![ihnorton](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/ihnorton/32/26_2.png) [@ihnorton](https://discourse.julialang.org/u/ihnorton)\
**Post date:** [April 19, 2017, 5:23pm UTC](https://discourse.julialang.org/t/embedding-ubuntu-ppa-library-location/3270/5 "2017-04-19T17:23:33Z")

</div>

> [@SylvainCorlay](#):
>
> directly requires knowing the full version string of libLLVM. If there was a cleaner way to retrieve this, it would be fantastic.

```julia
julia -e "println(Base.libllvm_version)"

```

---

<div class="post-metadata">

**Author:** ![SylvainCorlay](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/sylvaincorlay/32/923_2.png) [@SylvainCorlay](https://discourse.julialang.org/u/SylvainCorlay)\
**Post date:** [April 19, 2017, 5:30pm UTC](https://discourse.julialang.org/t/embedding-ubuntu-ppa-library-location/3270/6 "2017-04-19T17:30:17Z")

</div>

> [@ihnorton](#):
>
> julia -e “println(Base.libllvm\_version)”

Awesome!
