# InitError for a combination of ImageMagick and MATLAB

**URL:** <https://discourse.julialang.org/t/initerror-for-a-combination-of-imagemagick-and-matlab/16869>\
**Category:** General Usage\
**Tags:** question, error\
**Created:** [October 27, 2018, 6:53pm UTC](https://discourse.julialang.org/t/initerror-for-a-combination-of-imagemagick-and-matlab/16869 "2018-10-27T18:53:09Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [October 27, 2018, 6:53pm UTC](https://discourse.julialang.org/t/initerror-for-a-combination-of-imagemagick-and-matlab/16869/1 "2018-10-27T18:53:09Z")

</div>

I’d appreciate any help with this cryptic issue:  
Building a package with just two dependencies, `ImageMagick` and `MATLAB`, will result in this:

```julia
   _ _ _(_)_ | Documentation: https://docs.julialang.org
  (_) | (_) (_) |
   _ _ _| |_ __ _ | Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` | |
  | | |_| | | | (_| | | Version 1.0.1 (2018-09-29)
 _/ |\ __'_|_|_|\__'_| | Official https://julialang.org/ release
|__/ |

julia> using Kaka
[Info: Recompiling stale cache file /home/yakir/.julia/compiled/v1.0/Kaka/RH5vt.ji for Kaka [9b64631b-9168-58e0-9795-6abd08b5997b]
ERROR: InitError: error compiling __init__ : could not load library "/home/yakir/.julia/packages/ImageMagick/d5KBL/deps/usr/lib/libMagickWand-6.Q16.so"
/lib/x86_64-linux-gnu/libz.so.1: version `ZLIB_1.2.9' not found (required by /home/yakir/.julia/packages/ImageMagick/d5KBL/deps/usr/lib/libpng16.so.16)
Stacktrace:
 [1] _include_from_serialized(::String, ::Array{Any,1}) at ./loading.jl:630
 [2] macro expansion at ./logging.jl:312 [inlined]
 [3] _require_search_from_serialized(::Base.PkgId, ::String) at ./loading.jl:701
 [4] _tryrequire_from_serialized(::Base.PkgId, ::UInt64, ::Nothing) at ./loading.jl:645
 [5] _require_from_serialized(::String) at ./loading.jl:676
 [6] _require(::Base.PkgId) at ./logging.jl:317
 [7] require(::Base.PkgId) at ./loading.jl:855
 [8] macro expansion at ./logging.jl:311 [inlined]
 [9] require(::Module, ::Symbol) at ./loading.jl:837
during initialization of module ImageMagick

```

`Kaka` (excuse the name) `Project.toml`:

```nohighlight
name = "Kaka"
uuid = "9b64631b-9168-58e0-9795-6abd08b5997b"
authors = ["yakir12 <12.yakir@gmail.com>"]
version = "0.1.0"

[deps]
ImageMagick = "6218d12a-5da1-5696-b52f-db25d2ecc6d1"
MATLAB = "10e44e05-a98a-55b3-a45b-ba969058deb6"

[extras]
Test = "8dfed614-e22c-5e08-85e1-65c5234f0b40"

[targets]
test = ["Test"]

```

and source:

```julia
module Kaka
using ImageMagick, MATLAB
end # module

```

I posted an [issue in ImageMagick](https://github.com/JuliaIO/ImageMagick.jl/issues/142), but that might have been the wrong place?

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [October 29, 2018, 7:57am UTC](https://discourse.julialang.org/t/initerror-for-a-combination-of-imagemagick-and-matlab/16869/2 "2018-10-29T07:57:46Z")

</div>

More information about this bug can be found [here](https://github.com/JuliaGraphics/Gtk.jl/pull/387) and [here](https://discourse.julialang.org/t/dll-problems-episode-2/12405/12).

Switching the order of the two packages did not resolve this issue for me.

---

<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:** [October 29, 2018, 8:35am UTC](https://discourse.julialang.org/t/initerror-for-a-combination-of-imagemagick-and-matlab/16869/3 "2018-10-29T08:35:19Z")

</div>

> [@yakir12](#):
>
> /home/yakir/.julia/packages/ImageMagick/d5KBL/deps/usr/lib/

A shot in the dark and only a temporary workaround if it works. Try to start Julia with

```julia
LD_PRELOAD=/home/yakir/.julia/packages/ImageMagick/d5KBL/deps/usr/lib/libz.so julia

```

to force loading the newer version of `libz` before any dependency manages to bring in the old system `libz`.

---

<div class="post-metadata">

**Author:** ![yakir12](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/yakir12/32/297_2.png) [@yakir12](https://discourse.julialang.org/u/yakir12)\
**Post date:** [October 29, 2018, 8:47am UTC](https://discourse.julialang.org/t/initerror-for-a-combination-of-imagemagick-and-matlab/16869/4 "2018-10-29T08:47:11Z")

</div>

> [@GunnarFarneback](#):
>
> LD\_PRELOAD=/home/yakir/.julia/packages/ImageMagick/d5KBL/deps/usr/lib/libz.so julia

Worked! Thanks, I had no idea how to specify which `libz` julia should use. Awesome, thanks!
