Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error: could not load library libz #54

Closed
tbreloff opened this issue Jul 10, 2016 · 10 comments
Closed

Error: could not load library libz #54

tbreloff opened this issue Jul 10, 2016 · 10 comments

Comments

@tbreloff
Copy link

As reported by @juanklopper: JuliaPlots/Plots.jl#386 (comment)

@jiahao
Copy link
Contributor

jiahao commented Jul 11, 2016

reported on Mint 18

@haberdashPI
Copy link

haberdashPI commented Jan 29, 2018

Not sure if this is related, but I am getting a similar error on Mac OS X after running Pkg.update() today. Adding the following to my .juliarc.jl file resolved the problem.

push!(Libdl.DL_LOAD_PATH,"/usr/lib")

Though it seems odd to me that this would be necessary...

Here's the output before the fix:

using GZip
INFO: Precompiling module GZip.
ERROR: LoadError: LoadError: error compiling anonymous: could not load library "libz"
dlopen(libz.dylib, 1): image not found
Stacktrace:
 [1] include_from_node1(::String) at ./loading.jl:576
 [2] include(::String) at ./sysimg.jl:14
 [3] include_from_node1(::String) at ./loading.jl:576
 [4] include(::String) at ./sysimg.jl:14
 [5] anonymous at ./<missing>:2
while loading /Users/davidlittle/.julia/v0.6/GZip/src/zlib_h.jl, in expression starting on line 11
while loading /Users/davidlittle/.julia/v0.6/GZip/src/GZip.jl, in expression starting on line 75

@SimonDanisch
Copy link
Member

just a heads up:
JuliaLang/julia#22828 pretty much means that const _zlib = "libz" won't work on a lot of platforms, that only have e.g. libz.so.1 in their path.

@JBlaschke
Copy link

This seems to also be a problem on macOS 10.13.6 and Julia v0.7:
FluxML/Flux.jl#269 (comment)
even though macOS doesn't have a libz.so.1 (instead libz is usr/lib/libz.dylib)

@SimonDanisch
Copy link
Member

Yeah, that's exactly the issue! Anyways, just doing const _zlib = "libz" and then ccall((:func, _zlib), ...) is a very shaky way to rely on a binary dependency, so there are endless other ways to make this fail ;)
Maybe consider using: https://github.com/bicycle1885/CodecZlib.jl, which is using BinaryProvider to make sure that libz is installed!

@staticfloat
Copy link
Contributor

Just had another user run into this; they fixed it by installing zlib1g-dev on Ubuntu, but ever since JuliaLang/julia#22828 we need a better answer for this. Personally, even though it's very likely that libz.so is already installed and available, I think it's best if we use e.g. BinaryProvider for this, so I think it's best if we just include the deps/build.jl from CodecZlib.jl and steal the binaries from that package for now. ;)

@jpsamaroo
Copy link

I'll add my +1 to using BinaryProvider as opposed to using system libz. On Gentoo, /usr/lib64/libz.so is actually a linker script (for whatever reason), and so I get an "Invalid ELF header" error anytime I try to precompile this package or, say, Libz.jl.

@JBlaschke
Copy link

The work around that I found for macOS was to set DYLD_LIBRARY_PATH to /usr/lib (in my case, I've installed libz using Homebrew which links everything into /usr/lib). More details here: FluxML/Flux.jl#343 (comment)

Note that this will let you precompile, but if you do anything else with that DYLD_LIBRARY_PATH setting, you'll crash the Julia interpreter. So you need to restart Julia and fiddle with the environment variables every time GZip is updated.

Therefore I also think the BinaryProvider is a better solution

@jcheong0428
Copy link

#54 (comment) worked for me.
As a starter had to install Libdl first, and then push the library.

using Pkg
Pkg.add("Libdl")
using Libdl
push!(Libdl.DL_LOAD_PATH,"/usr/lib")

@shilangyu
Copy link

On fedora installing zlib-devel fixed it. Shouldn't external dependencies be listed in the README?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

10 participants