ngmlr icon indicating copy to clipboard operation
ngmlr copied to clipboard

Bug in CMakeLists.txt: cmake does not appropriately throw error if (or opt for dynamic libraries) when static ZLIB missing

Open mebbert opened this issue 7 years ago • 3 comments

Hi, I was having trouble compiling ngmlr yesterday. I was getting a linker error because of ZLIB:

ld: cannot find -lz

I was baffled that cmake was finding zlib, but the linker was failing. Essentially, the static zlib libraries were not installed.

I posted to Stack Overflow to understand whether it's possible to force cmake to throw an error if the static library is missing. Turns out you already have that, but it's being called after cmake finds ZLIB.

See Can CMake require static libraries (e.g., ZLIB)?

I was able to compile by commenting out

option(STATIC "Build static binary" ON)

mebbert avatar Jun 24 '17 22:06 mebbert

Thank you for the feedback!

Instead of commenting out the line you could also run cmake as follows: cmake -DSTATIC=OFF .. This will give you a dynamically linked executable.

However, to avoid problems, starting with the next version dynamic linking will be the default.

Best, Philipp

philres avatar Jun 26 '17 17:06 philres

Great.

We had the same issue!

On 6/27/17 3:04 AM, Philipp Rescheneder wrote:

Thank you for the feedback!

Instead of commenting out the line you could also run cmake as follows: |cmake -DSTATIC=OFF ..| This will give you a dynamically linked executable.

However, to avoid problems, starting with the next version dynamic linking will be the default.

Best, Philipp

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/philres/ngmlr/issues/22#issuecomment-311120677, or mute the thread https://github.com/notifications/unsubscribe-auth/AGLMhsoUI5J2IO04OfVXa4kd21o71HBmks5sH-SKgaJpZM4OEdLZ.

--

Benjamin Schwessinger PhD. Discovery Early Career Research Award Fellow Rathjen Lab Division of Plant Science Research School of Biology College of Medicine, Biology, and Environment Linnaeus Building (134), Linnaeus Way The Australian National University Canberra ACT 0200 Australia

M: +61 405 919 737 [email protected] lab webpage http://tinyurl.com/BenSchwessinger

twitter: @schwessinger http://twitter.com/schwessinger blog: http://blushgreengrassatafridayafternoon.wordpress.com/ google scholar: Benjamin Schwessinger http://scholar.google.com.au/citations?user=lEhYW3QAAAAJ&hl=en CRICOS Provider # 00120C

BenjaminSchwessinger avatar Jun 27 '17 01:06 BenjaminSchwessinger

I also moved SET(CMAKE_FIND_LIBRARY_SUFFIXES ".a") in front of find_package( ZLIB REQUIRED ) as suggested on stackoverflow.

So when using -DSTATIC=ON cmake should now throw an error.

Thanks again for the link.

philres avatar Jul 12 '17 17:07 philres