RejectedSoftware Forums

Sign up

Linker errors when running `dub test` (missing `-lz` flag?)

Hi all,

I'm having a play with vibe.d. My system is Ubuntu 16.04, with ldc 0.17.1 (based on dmd 2.068.2) and dub 0.9.24 installed.

Having checked out vibe.d 0.7.28, the library itself builds fine, but dub test results in a linker error when it tries to build __test_libevent__:

Using pkg-config to resolve library flags for libevent, libevent_pthreads, libssl, libcrypto.
ldc2 -of.dub/build/__test__libevent__-unittest-linux.posix-x86_64-ldc_0-F9418803257CF238A0FB42B114B26D80/__test__libevent__ -d-debug -g -unittest -w -oq -od=.dub/obj -d-version=VibeCustomMain -d-version=VibeLibeventDriver -d-version=Have_vibe_d -d-version=Have_vibe_d_core -d-version=Have_libevent -d-version=Have_openssl -d-version=Have_vibe_d_data -d-version=Have_vibe_d_utils -d-version=Have_vibe_d_diet -d-version=Have_vibe_d_http -d-version=Have_vibe_d_mail -d-version=Have_vibe_d_mongodb -d-version=Have_vibe_d_redis -d-version=Have_vibe_d_web -Isource/ -I../../../.dub/packages/libevent-2.0.1_2.0.16 -I../../../.dub/packages/openssl-1.1.4_1.0.1g ../../../../../tmp/dub_test_root-523e1c66-4cd1-4601-9046-5f6ff8822e4e.d source/vibe/d.d source/vibe/vibe.d source/vibe/appmain.d libvibe-d_mail.a libvibe-d_mongodb.a libvibe-d_redis.a libvibe-d_web.a libvibe-d_diet.a libvibe-d_http.a libvibe-d_core.a libvibe-d_data.a libvibe-d_utils.a -L=-levent_pthreads -L=-levent -L=-lssl -L=-lcrypto
/usr/bin/ld: libvibe-d_core.a(vibe.stream.zlib.o): undefined reference to symbol 'deflate'
//lib/x86_64-linux-gnu/libz.so.1: error adding symbols: DSO missing from command line
collect2: error: ld returned 1 exit status
Error: /usr/bin/gcc failed with status: 1
FAIL .dub/build/__test__libevent__-unittest-linux.posix-x86_64-ldc_0-F9418803257CF238A0FB42B114B26D80/ __test__libevent__ executable
ldc2 failed with exit code 1.

Looks like there's a missing -L=-lz in there, perhaps ... ? Can anyone advise on how to handle this?

Thanks & best wishes,

-- Joe

Re: Linker errors when running `dub test` (missing `-lz` flag?)

On Sun, 05 Jun 2016 12:30:50 GMT, Joseph Rushton Wakeling wrote:

Looks like there's a missing -L=-lz in there, perhaps ... ? Can anyone advise on how to handle this?

For the avoidance of doubt, zlib1g-dev 1.2.8 is installed.

Re: Linker errors when running `dub test` (missing `-lz` flag?)

On Sun, 05 Jun 2016 12:41:54 GMT, Joseph Rushton Wakeling wrote:

On Sun, 05 Jun 2016 12:30:50 GMT, Joseph Rushton Wakeling wrote:

Looks like there's a missing -L=-lz in there, perhaps ... ? Can anyone advise on how to handle this?

For the avoidance of doubt, zlib1g-dev 1.2.8 is installed.

My suspicion here is that vibe.d's build setup is perhaps assuming that zlib will have been statically built into phobos, while in the Debian/Ubuntu libphobos2-ldc* packages, it's dynamically linked against ... ?

Re: Linker errors when running `dub test` (missing `-lz` flag?)

On Sun, 05 Jun 2016 12:45:18 GMT, Joseph Rushton Wakeling wrote:

On Sun, 05 Jun 2016 12:41:54 GMT, Joseph Rushton Wakeling wrote:

On Sun, 05 Jun 2016 12:30:50 GMT, Joseph Rushton Wakeling wrote:

Looks like there's a missing -L=-lz in there, perhaps ... ? Can anyone advise on how to handle this?

For the avoidance of doubt, zlib1g-dev 1.2.8 is installed.

My suspicion here is that vibe.d's build setup is perhaps assuming that zlib will have been statically built into phobos, while in the Debian/Ubuntu libphobos2-ldc* packages, it's dynamically linked against ... ?

Adding "lflags": ["-lz"] to dub.json fixes the issue, in any case.

This is probably more of a dub problem than a vibe.d one, perhaps making the assumption that druntime and phobos have no dynamically-linked dependencies ... ?

Re: Linker errors when running `dub test` (missing `-lz` flag?)

On Sun, 05 Jun 2016 12:50:04 GMT, Joseph Rushton Wakeling wrote:

On Sun, 05 Jun 2016 12:45:18 GMT, Joseph Rushton Wakeling wrote:

On Sun, 05 Jun 2016 12:41:54 GMT, Joseph Rushton Wakeling wrote:

On Sun, 05 Jun 2016 12:30:50 GMT, Joseph Rushton Wakeling wrote:

Looks like there's a missing -L=-lz in there, perhaps ... ? Can anyone advise on how to handle this?

For the avoidance of doubt, zlib1g-dev 1.2.8 is installed.

My suspicion here is that vibe.d's build setup is perhaps assuming that zlib will have been statically built into phobos, while in the Debian/Ubuntu libphobos2-ldc* packages, it's dynamically linked against ... ?

Adding "lflags": ["-lz"] to dub.json fixes the issue, in any case.

This is probably more of a dub problem than a vibe.d one, perhaps making the assumption that druntime and phobos have no dynamically-linked dependencies ... ?

There is an open issue for this: #1458

I kind of forgot about it, but I'll add a fix to dub.json right now.

Re: Linker errors when running `dub test` (missing `-lz` flag?)

Am 20.06.2016 um 18:17 schrieb Sönke Ludwig:

On Sun, 05 Jun 2016 12:50:04 GMT, Joseph Rushton Wakeling wrote:

On Sun, 05 Jun 2016 12:45:18 GMT, Joseph Rushton Wakeling wrote:

On Sun, 05 Jun 2016 12:41:54 GMT, Joseph Rushton Wakeling wrote:

On Sun, 05 Jun 2016 12:30:50 GMT, Joseph Rushton Wakeling wrote:

Looks like there's a missing -L=-lz in there, perhaps ... ? Can anyone advise on how to handle this?

For the avoidance of doubt, zlib1g-dev 1.2.8 is installed.

My suspicion here is that vibe.d's build setup is perhaps assuming that zlib will have been statically built into phobos, while in the Debian/Ubuntu libphobos2-ldc* packages, it's dynamically linked against ... ?

Adding "lflags": ["-lz"] to dub.json fixes the issue, in any case.

This is probably more of a dub problem than a vibe.d one, perhaps making the assumption that druntime and phobos have no dynamically-linked dependencies ... ?

There is an open issue for this: #1458

I kind of forgot about it, but I'll add a fix to dub.json right now.

I tested with the vanilla binaries (0.17.1 and 1.0.0) and both work for
me on Mint 0.17.3. Are the .deb packages from the official Debian
repositories or from D-APT (or from somewhere else)?

Adding -lz doesn't break anything, though, so I guess I can just add
it anyway. Would just be nice to be able to verify that it works.