www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - undefined reference to 'deflateEnd'

reply Andre Pany <andre s-e-a-p.de> writes:
Hi,

I have some issues, the get this program working on ubuntu:

``` Dockerfile
FROM ubuntu:focal

RUN apt-get update && apt-get upgrade -y \
     && apt-get install --no-install-recommends -y build-essential 
ldc dub zlib1g-dev

COPY app.d /tmp/
RUN dub build --single /tmp/app.d -v
```

``` app.d
/+ dub.sdl:
     name "app"
     lflags "-lz" "-ldl"
     dflags "-static"
+/
import std;
void main(){}
```

Linker fails with error messages like these:
/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libphobos2-ld
.a(zlib.o):function _D3std4zlib8Compress5errorMFiZv: error: undefined reference
to 'deflateEnd'
/usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libphobos2-ld
.a(zlib.o):function _D3std4zlib8Compress6__dtorMFZv: error: undefined reference
to 'deflateEnd'

The actual link command looks right:
/usr/bin/ldc2 
-oftmp/.dub/build/application-debug-linux.posix-x86_64-ldc_2090-ED4668B88284A40F
4668246697CB2B5/app tmp/.dub/build/application-debug-linux.posix-x86_64-ldc_2090-ED4668B88284A40FA4
68246697CB2B5/app.o -L--no-as-needed -L-lz -L-ldl -static -g

Do you have an idea?

Kind regards
André
May 17 2020
parent reply ikod <igor.khasilev gmail.com> writes:
On Monday, 18 May 2020 at 05:01:45 UTC, Andre Pany wrote:
 Hi,

 I have some issues, the get this program working on ubuntu:

 ``` Dockerfile
 FROM ubuntu:focal

 RUN apt-get update && apt-get upgrade -y \
     && apt-get install --no-install-recommends -y 
 build-essential ldc dub zlib1g-dev

 COPY app.d /tmp/
 RUN dub build --single /tmp/app.d -v
 ```

 ``` app.d
 /+ dub.sdl:
     name "app"
     lflags "-lz" "-ldl"
     dflags "-static"
 +/
 import std;
 void main(){}
 ```

 Linker fails with error messages like these:
 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libphobos2-ld
.a(zlib.o):function _D3std4zlib8Compress5errorMFiZv: error: undefined reference
to 'deflateEnd'
 /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/libphobos2-ld
.a(zlib.o):function _D3std4zlib8Compress6__dtorMFZv: error: undefined reference
to 'deflateEnd'

 The actual link command looks right:
 /usr/bin/ldc2 
 -oftmp/.dub/build/application-debug-linux.posix-x86_64-ldc_2090-ED4668B88284A40F
4668246697CB2B5/app tmp/.dub/build/application-debug-linux.posix-x86_64-ldc_2090-ED4668B88284A40FA4
68246697CB2B5/app.o -L--no-as-needed -L-lz -L-ldl -static -g

 Do you have an idea?

 Kind regards
 André
NAME="Ubuntu" VERSION="18.04.4 LTS (Bionic Beaver)" Works for me on ubuntu when changed dflags to lflags: /+ dub.sdl: name "app" lflags "-lz" "-ldl" lflags "-static" +/ import std; void main(){} /usr/bin/dmd -c -of.dub/build/application-debug-linux.posix-x86_64-dmd_2089-1D31FAC5109A6D2373 AB3139BEB0877/app.o -debug -g -w -version=Have_app t.d -vcolumns Linking... /usr/bin/dmd -of.dub/build/application-debug-linux.posix-x86_64-dmd_2089-1D31FAC5109A6D23 3EAB3139BEB0877/app .dub/build/application-debug-linux.posix-x86_64-dmd_2089-1D31FAC5109A6D2373 AB3139BEB0877/app.o -L--no-as-needed -L-lz -L-ldl -L-static -g Copying target from /tmp/test/.dub/build/application-debug-linux.posix-x86_64-dmd_2089-1D31FAC5109A6D23 3EAB3139BEB0877/app to /tmp/test Running ./app
May 17 2020
parent reply Andre Pany <andre s-e-a-p.de> writes:
On Monday, 18 May 2020 at 06:02:03 UTC, ikod wrote:
 NAME="Ubuntu"
 VERSION="18.04.4 LTS (Bionic Beaver)"

 [...]
Thanks a lot. Kind regards André
May 18 2020
parent ikod <geller.garry gmail.com> writes:
On Monday, 18 May 2020 at 07:33:29 UTC, Andre Pany wrote:
 On Monday, 18 May 2020 at 06:02:03 UTC, ikod wrote:
 NAME="Ubuntu"
 VERSION="18.04.4 LTS (Bionic Beaver)"

 [...]
Thanks a lot. Kind regards André
Just discovered that we can import etc.c.zlib and use low level zlib directly
May 18 2020