mingw ld cannot link libraries

Bug #1804138 reported by kyonides
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
binutils-mingw-w64 (Ubuntu)
Incomplete
Undecided
Stephen Kitt

Bug Description

On Kubuntu Bionic Beaver this is what happens if I try to find any library to link it at the end of the compiling process.

x86_64-w64-mingw32-ld -lz --verbose
GNU ld (GNU Binutils) 2.30
  Supported emulations:
   i386pep
   i386pe
using internal linker script:
=================================
A large script inbetween
=================================
attempt to open no/usr/local/lib/x86_64-linux-gnu/libz.dll.a failed
attempt to open no/usr/local/lib/x86_64-linux-gnu/z.dll.a failed
attempt to open no/usr/local/lib/x86_64-linux-gnu/libz.a failed
attempt to open no/usr/local/lib/x86_64-linux-gnu/z.lib failed
attempt to open no/usr/local/lib/x86_64-linux-gnu/libz.dll failed
attempt to open no/usr/local/lib/x86_64-linux-gnu/z.dll failed
attempt to open no/usr/local/lib/x86_64-linux-gnu/libz.a failed
attempt to open no/lib/x86_64-linux-gnu/libz.dll.a failed
attempt to open no/lib/x86_64-linux-gnu/z.dll.a failed
attempt to open no/lib/x86_64-linux-gnu/libz.a failed
attempt to open no/lib/x86_64-linux-gnu/z.lib failed
attempt to open no/lib/x86_64-linux-gnu/libz.dll failed
attempt to open no/lib/x86_64-linux-gnu/z.dll failed
attempt to open no/lib/x86_64-linux-gnu/libz.a failed
attempt to open no/usr/lib/x86_64-linux-gnu/libz.dll.a failed
attempt to open no/usr/lib/x86_64-linux-gnu/z.dll.a failed
attempt to open no/usr/lib/x86_64-linux-gnu/libz.a failed
attempt to open no/usr/lib/x86_64-linux-gnu/z.lib failed
attempt to open no/usr/lib/x86_64-linux-gnu/libz.dll failed
attempt to open no/usr/lib/x86_64-linux-gnu/z.dll failed
attempt to open no/usr/lib/x86_64-linux-gnu/libz.a failed
attempt to open no/usr/local/lib/libz.dll.a failed
attempt to open no/usr/local/lib/z.dll.a failed
attempt to open no/usr/local/lib/libz.a failed
attempt to open no/usr/local/lib/z.lib failed
attempt to open no/usr/local/lib/libz.dll failed
attempt to open no/usr/local/lib/z.dll failed
attempt to open no/usr/local/lib/libz.a failed
attempt to open no/lib/libz.dll.a failed
attempt to open no/lib/z.dll.a failed
attempt to open no/lib/libz.a failed
attempt to open no/lib/z.lib failed
attempt to open no/lib/libz.dll failed
attempt to open no/lib/z.dll failed
attempt to open no/lib/libz.a failed
attempt to open no/usr/lib/libz.dll.a failed
attempt to open no/usr/lib/z.dll.a failed
attempt to open no/usr/lib/libz.a failed
attempt to open no/usr/lib/z.lib failed
attempt to open no/usr/lib/libz.dll failed
attempt to open no/usr/lib/z.dll failed
attempt to open no/usr/lib/libz.a failed
attempt to open no/usr/x86_64-w64-mingw32/lib/libz.dll.a failed
attempt to open no/usr/x86_64-w64-mingw32/lib/z.dll.a failed
attempt to open no/usr/x86_64-w64-mingw32/lib/libz.a failed
attempt to open no/usr/x86_64-w64-mingw32/lib/z.lib failed
attempt to open no/usr/x86_64-w64-mingw32/lib/libz.dll failed
attempt to open no/usr/x86_64-w64-mingw32/lib/z.dll failed
attempt to open no/usr/x86_64-w64-mingw32/lib/libz.a failed
attempt to open no/usr/local/lib/x86_64-linux-gnu/libz.dll.a failed
attempt to open no/usr/local/lib/x86_64-linux-gnu/z.dll.a failed
attempt to open no/usr/local/lib/x86_64-linux-gnu/libz.a failed
attempt to open no/usr/local/lib/x86_64-linux-gnu/z.lib failed
attempt to open no/usr/local/lib/x86_64-linux-gnu/libz.dll failed
attempt to open no/usr/local/lib/x86_64-linux-gnu/z.dll failed
attempt to open no/usr/local/lib/x86_64-linux-gnu/z.lib failed
attempt to open no/lib/x86_64-linux-gnu/libz.dll.a failed
attempt to open no/lib/x86_64-linux-gnu/z.dll.a failed
attempt to open no/lib/x86_64-linux-gnu/libz.a failed
attempt to open no/lib/x86_64-linux-gnu/z.lib failed
attempt to open no/lib/x86_64-linux-gnu/libz.dll failed
attempt to open no/lib/x86_64-linux-gnu/z.dll failed
attempt to open no/lib/x86_64-linux-gnu/z.lib failed
attempt to open no/usr/lib/x86_64-linux-gnu/libz.dll.a failed
attempt to open no/usr/lib/x86_64-linux-gnu/z.dll.a failed
attempt to open no/usr/lib/x86_64-linux-gnu/libz.a failed
attempt to open no/usr/lib/x86_64-linux-gnu/z.lib failed
attempt to open no/usr/lib/x86_64-linux-gnu/libz.dll failed
attempt to open no/usr/lib/x86_64-linux-gnu/z.dll failed
attempt to open no/usr/lib/x86_64-linux-gnu/z.lib failed
attempt to open no/usr/local/lib/libz.dll.a failed
attempt to open no/usr/local/lib/z.dll.a failed
attempt to open no/usr/local/lib/libz.a failed
attempt to open no/usr/local/lib/z.lib failed
attempt to open no/usr/local/lib/libz.dll failed
attempt to open no/usr/local/lib/z.dll failed
attempt to open no/usr/local/lib/z.lib failed
attempt to open no/lib/libz.dll.a failed
attempt to open no/lib/z.dll.a failed
attempt to open no/lib/libz.a failed
attempt to open no/lib/z.lib failed
attempt to open no/lib/libz.dll failed
attempt to open no/lib/z.dll failed
attempt to open no/lib/z.lib failed
attempt to open no/usr/lib/libz.dll.a failed
attempt to open no/usr/lib/z.dll.a failed
attempt to open no/usr/lib/libz.a failed
attempt to open no/usr/lib/z.lib failed
attempt to open no/usr/lib/libz.dll failed
attempt to open no/usr/lib/z.dll failed
attempt to open no/usr/lib/z.lib failed
attempt to open no/usr/x86_64-w64-mingw32/lib/libz.dll.a failed
attempt to open no/usr/x86_64-w64-mingw32/lib/z.dll.a failed
attempt to open no/usr/x86_64-w64-mingw32/lib/libz.a failed
attempt to open no/usr/x86_64-w64-mingw32/lib/z.lib failed
attempt to open no/usr/x86_64-w64-mingw32/lib/libz.dll failed
attempt to open no/usr/x86_64-w64-mingw32/lib/z.dll failed
attempt to open no/usr/x86_64-w64-mingw32/lib/z.lib failed
x86_64-w64-mingw32-ld: cannot find -lz

If I check the /usr/x86_64-w64-mingw32/lib/ path in dolphin or konqueror I do find the libz.a and libz.dll.a files right there. I know they are not supposed to be included with the mingw packages, but the same happens to any library that is included by default.

Thereafter I came up with the idea that creating pc files myself would probably fix this situation so I did. Even if pkg-config and cmake say they have found the packages (including binaries, included header files, and libraries), the linker just denies they can be found anywhere. Even if it was a crazy idea, I used the default ld to try compile my custom project and it did find all of the specified libraries without any issues. Of course the result was not good at all for ld thought it was linking common Linux libraries XD

By the way, I also exported a custom location for the pkg-config files and double checked it with echo $PKG_CONFIG_PATH, and still mingw ld was unable to find the packages =_=

kyonides (kyonides)
description: updated
kyonides (kyonides)
description: updated
Revision history for this message
Stephen Kitt (steve-sk2) wrote :

It seems that ld is using “no” as a sysroot. The interesting part here is in the “large script” you removed; could you at least tell me what the “SEARCH_DIR” setting is, near the start of the script?

Changed in gcc-mingw-w64 (Ubuntu):
assignee: nobody → Stephen Kitt (steve-sk2)
status: New → Incomplete
affects: gcc-mingw-w64 (Ubuntu) → binutils-mingw-w64 (Ubuntu)
Changed in binutils-mingw-w64 (Ubuntu):
assignee: Stephen Kitt (steve-sk2) → nobody
Stephen Kitt (steve-sk2)
Changed in binutils-mingw-w64 (Ubuntu):
assignee: nobody → Stephen Kitt (steve-sk2)
Revision history for this message
kyonides (kyonides) wrote :

I guess you mean this...

OUTPUT_FORMAT(pei-x86-64)
SEARCH_DIR("=/usr/local/lib/x86_64-linux-gnu"); SEARCH_DIR("=/lib/x86_64-linux-gnu"); SEARCH_DIR("=/usr/lib/x86_64-linux-gnu"); SEARCH_DIR("=/usr/local/lib"); SEARCH_DIR("=/lib"); SEARCH_DIR("=/usr/lib"); SEARCH_DIR("=/usr/x86_64-w64-mingw32/lib");
SECTIONS
{
# more lines of code...

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.