Thread overview
Linker error under Ubuntu
May 14, 2020
solidstate1991
May 15, 2020
evilrat
May 15, 2020
solidstate1991
May 16, 2020
evilrat
May 16, 2020
kinke
May 14, 2020
When I try to compile my own project under Ubuntu with dub, I get the following linker error:

/usr/bin/ld: .dub/obj/pixelperfectengine_pixelperfecteditor.o: undefined reference to symbol 'inflateEnd'
//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
/usr/bin/ldc2 failed with exit code 1.

I've checked for zlib and it was already preinstalled. I tried to install LLD, but that didn't help.

The latest version of my project found here: https://github.com/ZILtoid1991/pixelperfectengine
May 15, 2020
On Thursday, 14 May 2020 at 16:09:16 UTC, solidstate1991 wrote:
> When I try to compile my own project under Ubuntu with dub, I get the following linker error:
>
> /usr/bin/ld: .dub/obj/pixelperfectengine_pixelperfecteditor.o: undefined reference to symbol 'inflateEnd'
> //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
> /usr/bin/ldc2 failed with exit code 1.
>
> I've checked for zlib and it was already preinstalled. I tried to install LLD, but that didn't help.
>
> The latest version of my project found here: https://github.com/ZILtoid1991/pixelperfectengine

Um, pardon the stupid question, but did you just forgot to link it? I can't see a mention of it anywhere in both the old json and dub.sdl, and I don't see subpackages either. (does it links implicitly by the compiler?)

Also if it's digged up somewhere, another possibility is the link order issue(you need to put libs in order that adds linker symbols for previous libs to consume, for circular dependencies you can specify libs multiple times). The MS linker and LLVM linkers(not sure about GNU gold) does some work for you so you don't have to reorder libs most of the time.
May 15, 2020
On Friday, 15 May 2020 at 03:46:57 UTC, evilrat wrote:
>
> Um, pardon the stupid question, but did you just forgot to link it? I can't see a mention of it anywhere in both the old json and dub.sdl, and I don't see subpackages either. (does it links implicitly by the compiler?)
>
> Also if it's digged up somewhere, another possibility is the link order issue(you need to put libs in order that adds linker symbols for previous libs to consume, for circular dependencies you can specify libs multiple times). The MS linker and LLVM linkers(not sure about GNU gold) does some work for you so you don't have to reorder libs most of the time.

Dub should do the linking by itself.
May 16, 2020
On Friday, 15 May 2020 at 23:49:37 UTC, solidstate1991 wrote:
>
> Dub should do the linking by itself.

How does it know what to link?

May 16, 2020
On Thursday, 14 May 2020 at 16:09:16 UTC, solidstate1991 wrote:
> When I try to compile my own project under Ubuntu with dub, I get the following linker error:
>
> /usr/bin/ld: .dub/obj/pixelperfectengine_pixelperfecteditor.o: undefined reference to symbol 'inflateEnd'
> //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
> /usr/bin/ldc2 failed with exit code 1.

This sounds like a misconfigured distro-LDC. zlib is usually integrated into libphobos, but distros tend to favor the distro's libz.so and patch it out. That must be handled in /etc/ldc2.conf though, with something like `-defaultlib=phobos2-ldc,z,druntime-ldc` (and possibly a zlib1g-dev package dependency).