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

Linker error in libz on Ubuntu 16.04 #62

Closed
nethraravindran opened this issue Aug 13, 2018 · 10 comments
Closed

Linker error in libz on Ubuntu 16.04 #62

nethraravindran opened this issue Aug 13, 2018 · 10 comments

Comments

@nethraravindran
Copy link
Contributor

nethraravindran commented Aug 13, 2018

Linking ./.build/x86_64-unknown-linux/debug/KituraPackageTests.xctest
/root/Kitura/.build/x86_64-unknown-linux/debug/NIOHTTP1.build/HTTPResponseCompressor.swift.o:/root/Kitura/.build/x86_64-unknown-linux/debug/NIOHTTP1.build/HTTPResponseCompressor.swift.o:function _T08NIOHTTP122HTTPResponseCompressorC19deinitializeEncoder33_E8A369BA8CC72FD6D05117C456504CA2LLyyF: error: undefined reference to 'deflateEnd'
/root/Kitura/.build/x86_64-unknown-linux/debug/NIOHTTP1.build/HTTPResponseCompressor.swift.o:/root/Kitura/.build/x86_64-unknown-linux/debug/NIOHTTP1.build/HTTPResponseCompressor.swift.o:function _T08NIOHTTP119PartialHTTPResponse33_E8A369BA8CC72FD6D05117C456504CA2LLV12compressBody3NIO10ByteBufferVSgSC10z_stream_sVz10compressor_AF0oP9AllocatorV9allocators5Int32V4flagtF: error: undefined reference to 'deflateBound'
/root/Kitura/.build/x86_64-unknown-linux/debug/NIOHTTP1.build/HTTPResponseCompressor.swift.o:/root/Kitura/.build/x86_64-unknown-linux/debug/NIOHTTP1.build/HTTPResponseCompressor.swift.o:function _T0SC10z_stream_sV8NIOHTTP1E15deflateToBuffer33_E8A369BA8CC72FD6D05117C456504CA2LLs5Int32V3NIO04ByteE0Vz6buffer_AG4flagtFSis016UnsafeMutableRawE7PointerVcfU_: error: undefined reference to 'deflate'
/root/Kitura/.build/x86_64-unknown-linux/debug/NIOHTTP1.build/HTTPResponseCompressor.swift.o:/root/Kitura/.build/x86_64-unknown-linux/debug/NIOHTTP1.build/HTTPResponseCompressor.swift.o:function CNIOZlib_deflateInit2: error: undefined reference to 'deflateInit2_'
clang: error: linker command failed with exit code 1 (use -v to see invocation)
<unknown>:0: error: link command failed with exit code 1 (use -v to see invocation)

swift test -Xlinker -lz is used as a temporary work-around for the above issue.

@nethraravindran nethraravindran changed the title Linker error in libz on Ubuntu Linker error in libz on Linux Aug 13, 2018
@pushkarnk
Copy link
Contributor

@nethraravindran Does this happen on both 14.04 and 16.04?

@nethraravindran
Copy link
Contributor Author

@pushkarnk No, this doesn't happen on 14.04

@pushkarnk pushkarnk changed the title Linker error in libz on Linux Linker error in libz on Ubuntu 16.04 Aug 20, 2018
@pushkarnk
Copy link
Contributor

pushkarnk commented Aug 20, 2018

I found a handful of projects/forums in which this problem was discussed:

https://elixirforum.com/t/ubuntu-exec-erlexec-not-found/10499/6
ncmpcpp/ncmpcpp#138
TrinityCore/TrinityCore#19074
grpc/grpc#11768

All of them talk about solving the problem using -lz but there's no drill-down into why this problem didn't show up on Ubuntu 14.04.

On Ubuntu 16.04, I ran ldconfig and I can see libz present in the search path:

ldconfig -v | grep "libz"
	libz.so.1 -> libz.so.1.2.8

@ianpartridge
Copy link
Contributor

Does the linking still fail if we add CNIOZlib to the dependencies of the KituraNet target?

@weissi
Copy link

weissi commented Aug 21, 2018

That sounds to me like either zlib or pkg-config isn't installed. You can test this by running

pkg-config --libs zlib

which should output

-lz

Or (on Debian systems) you should be able to see if zlib is installed with development headers like this

dpkg -l zlib1g-dev

@pushkarnk
Copy link
Contributor

Thanks @weissi - Didn't know about pkg-config necessity. The xenial docker images have zlib installed (as seen in the ldconfig output), but not pkg-config. Simply installing pkg-config resolves the problem 🤔

@pushkarnk
Copy link
Contributor

And I can see that the trusty images (Ubuntu 14.04) have pkg-config pre-installed.

@pushkarnk
Copy link
Contributor

@nethraravindran Can we try adding pkg-config to the apt-get install .... list in build.sh

@nethraravindran
Copy link
Contributor Author

@pushkarnk Sure! Have created the PR :https://github.com/IBM-Swift/Kitura-NIO/pull/77

@nethraravindran
Copy link
Contributor Author

PR merged. Closing this issue.

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

4 participants