# BinaryBuilder cross-coompilation env needs an additional library

**URL:** <https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505>\
**Category:** General Usage\
**Tags:** question, binarybuilder\
**Created:** [November 20, 2020, 4:41pm UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505 "2020-11-20T16:41:32Z")\
**Posts on this page:** 13\
**Page:** 1

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [November 20, 2020, 4:41pm UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505/1 "2020-11-20T16:41:32Z")

</div>

I am trying to include a C++ library with julia package. After BinaryBuilder’s wizard drops me into cross-compilation environment, the configure script that I sun within the source directory informs me that I need an additional library, say, libxxx-dev. So what is the correct procedure; do I add this library using apk tool? (the library is included among the ones distributed with julia compiler, in /usr/local/julia-1.5.3/libs)

Thanks

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 20, 2020, 5:13pm UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505/2 "2020-11-20T17:13:09Z")

</div>

> [@Mikhail\_Kagalenko](#):
>
> do I add this library using apk tool?

No: [FAQ · BinaryBuilder.jl](https://juliapackaging.github.io/BinaryBuilder.jl/latest/FAQ/#Can-I-install-packages-in-the-build-environment?-1)

> [@](#):
>
> The build environment is based on Alpine Linux (triplet: `x86_64-linux-musl` ) so you can use [`apk`](https://wiki.alpinelinux.org/wiki/Alpine_Linux_package_management) to install packages in it. However, if you need runtime libraries or programs for the target system these packages won’t help you. The package manager is useful only to install utilities, tools or libraries that are needed exclusively at compile time on the build system

You need to install the dependencies for the _target_ system, using other JLL packages when the wizard asks you so at the beginning. Inside the wizard build environment you can run

```julia
bb add Package_jll

```

to install that dependency

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [November 20, 2020, 5:52pm UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505/3 "2020-11-20T17:52:25Z")

</div>

Aha! Thanks. So, presumably, this will know to add the correct version of libxxx-dev, the same as the one that julia compiler ships with?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 20, 2020, 6:01pm UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505/4 "2020-11-20T18:01:57Z")

</div>

Yes (if I understood the question correctly, which I’m not 100% sure about)

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [November 20, 2020, 6:24pm UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505/5 "2020-11-20T18:24:20Z")

</div>

The question is, the C++ library configure script stops because libgmp-dev is not available within the cross-compile environment. A version of Libgmp is included within julia distribution. So if I include GMP@ 6.1.2 from Yggdrasil, that will add to the build environment the same version as the one shipped with the compiler, and when my \_jll package is installed, it will not need to download libgmp. Correct?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 20, 2020, 7:40pm UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505/6 "2020-11-20T19:40:45Z")

</div>

Uhm, the wizard doesn’t handle different versions very nicely. You can continue with whatever the wizard will install and we can fix it when you open the PR for Yggdrasil (which I assume is what you’re going to do?).

I warmly recommend you to write a `build_tarballs.sh` script, see [Building Packages · BinaryBuilder.jl](https://juliapackaging.github.io/BinaryBuilder.jl/dev/building/) or just start from another simple script that you can find in Yggdrasil. It’s _ **way** _ easier if you need to restart from scratch multiple times.

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [November 20, 2020, 8:54pm UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505/7 "2020-11-20T20:54:40Z")

</div>

I think you’re misunderstanding me somewhat. I don’t have a preference for any particular version of libgmp. I just want to compile the C++ library with the same libgmp as julia uses.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 20, 2020, 9:02pm UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505/8 "2020-11-20T21:02:59Z")

</div>

> [@Mikhail\_Kagalenko](#):
>
> I just want to compile the C++ library with the same libgmp as julia uses.

I’m referring to that 🙂

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [November 25, 2020, 10:34am UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505/9 "2020-11-25T10:34:09Z")

</div>

The [build script](https://github.com/JuliaPackaging/Yggdrasil/blob/master/M/MPSolve/build_tarballs.jl) refers to the particular version of libgmp. If I am interpreting the contents of julia artifacts’ directory correctly, it is the same libgmp as the julia ships with. Thus, in the Julia code that makes use of MPSolve\_jll it should be safe to `ccall((..., :libgmp))`, shouldn’t it? Or is it actually safer to use libgmp from within MPSolve\_jll namespace, like this: `ccall((..., MPSolve_jll.libgmp))`?

I tried getting a handle with `dlopen()` to both `:libgmp` and `MPSolve_jll.libgmp`, and the pointer returned is the same. The question is, would it stay the same in future releases?

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 25, 2020, 10:58am UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505/10 "2020-11-25T10:58:41Z")

</div>

GMP is loaded by Julia, yes. If you need to call into it you can either do

```julia
using GMP_jll
ccall((:func_name, libgmp), ...)

```

or

```julia
ccall((:func_name, :libgmp), ...)

```

like Julia Base does

---

<div class="post-metadata">

**Author:** ![Mikhail\_Kagalenko](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mikhail_kagalenko/32/13257_2.png) [@Mikhail\_Kagalenko](https://discourse.julialang.org/u/Mikhail_Kagalenko)\
**Post date:** [November 25, 2020, 11:59am UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505/11 "2020-11-25T11:59:01Z")

</div>

I know that I can. What I am concerned about is making sure this `libgmp` is the same one that libmps is built against, because I am passing `GMP` types to ````MPsolve```.

---

<div class="post-metadata">

**Author:** ![giordano](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/giordano/32/2166_2.png) [@giordano](https://discourse.julialang.org/u/giordano)\
**Post date:** [November 25, 2020, 12:07pm UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505/12 "2020-11-25T12:07:54Z")

</div>

As far as I know (I think @fingolfin knows more than me in this regard), if you target GMP v6.1, your code should work also with v6.2, there haven’t been breaking changes.

---

<div class="post-metadata">

**Author:** ![fingolfin](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fingolfin/32/6033_2.png) [@fingolfin](https://discourse.julialang.org/u/fingolfin)\
**Post date:** [November 25, 2020, 4:28pm UTC](https://discourse.julialang.org/t/binarybuilder-cross-coompilation-env-needs-an-additional-library/50505/13 "2020-11-25T16:28:46Z")

</div>

@giordano is completely right. Just make sure to build the JLL against GMP 6.1.2, not against 6.2.0, otherwise there are silly issues on macOS.
