Skip to content

CMake: link libm after libpng for static builds - #457

Open
skal65535 wants to merge 1 commit into
mozilla:masterfrom
skal65535:fix-static-libpng-link
Open

CMake: link libm after libpng for static builds#457
skal65535 wants to merge 1 commit into
mozilla:masterfrom
skal65535:fix-static-libpng-link

Conversation

@skal65535

Copy link
Copy Markdown

-DBUILD_SHARED_LIBS=OFF fails to link cjpeg-static / djpeg-static:

/usr/lib/x86_64-linux-gnu/libpng.a(png.c.o): undefined reference to `floor'
/usr/lib/x86_64-linux-gnu/libpng.a(png.c.o): undefined reference to `pow'

m is linked before ${PNG_LIBRARY}, so libpng.a is scanned once libm is
already past. Shared builds are unaffected — sharedlib/ finds libpng.so
before the static suffix override.

Link m again after PNG/ZLIB.

Verified on Ubuntu 26.04 / gcc 15.2: static build links, and PNG input works
(cjpeg-static in.png).

-lm is added before ${PNG_LIBRARY}, so libpng.a is scanned once libm is
already past and static builds fail:

  libpng.a(png.c.o): undefined reference to `floor'

Link m again after PNG/ZLIB for cjpeg-static and djpeg-static.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant