dfhack icon indicating copy to clipboard operation
dfhack copied to clipboard

CMake finds the 32-bit libz by default on 64-bit Linux systems.

Open ShimmerFairy opened this issue 3 years ago • 3 comments

I ran into this issue when building xlsxreader.plug.so, specifically looking like this:

[ 62%] Linking CXX shared module xlsxreader.plug.so
/usr/lib/gcc/x86_64-pc-linux-gnu/11.1.0/../../../../x86_64-pc-linux-gnu/bin/ld: /usr/lib/libz.so: error adding symbols: file in wrong format
collect2: error: ld returned 1 exit status

The issue here is that /usr/lib/libz.so is the 32-bit version of the library. On many (if not most) systems, the 64-bit version is found in /usr/lib64/libz.so, and indeed manually setting ZLIB_LIBRARY_RELEASE to the correct path allowed the build to finish successfully.

ShimmerFairy avatar Jun 04 '21 13:06 ShimmerFairy

Could you share some more details about your distro? On Ubuntu, I have /usr/lib/i386-linux-gnu/libz.so and /usr/lib/x86_64-linux-gnu/libz.so, but no /usr/lib/libz.so, and I'm surprised that your zlib in /usr/lib is not the "native" (64-bit) build - I'd expect the 32-bit one to be in /usr/lib32 or somewhere else on a 64-bit OS. Are you running a 32-bit kernel with 64-bit userland support somehow?

Here is where we set the zlib search path, for reference. It only has a special case for 32-bit Linux; as far as I know (and on my end) it hasn't failed on 64-bit Linux before. Could you try adding message("ZLIB_ROOT = ${ZLIB_ROOT}") before and after the find_package call here and report what it prints out?

lethosor avatar Jun 04 '21 16:06 lethosor

@ShimmerFairy another question: what CMake version are you using? The FindZlib module we're using is built in to CMake, so it's possible that upgrading to a newer version would help.

lethosor avatar Jun 19 '21 01:06 lethosor

Is this still an issue?

myk002 avatar Oct 08 '22 00:10 myk002

Closing for now. Please reopen if this is still an issue.

myk002 avatar Oct 19 '22 23:10 myk002