Skip to content

Fix Mac build failure with zlib static library detection#13

Draft
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-12
Draft

Fix Mac build failure with zlib static library detection#13
Copilot wants to merge 2 commits intomasterfrom
copilot/fix-12

Conversation

Copy link
Copy Markdown

Copilot AI commented Sep 14, 2025

This PR fixes the Mac build failure where cargo build would fail with:

error: could not find native static library `zlib`, perhaps an -L flag is missing?

The issue was caused by multiple problems in the zlib-ng build process:

  1. Silent CMake failures: The build script didn't check for CMake errors, so compilation issues in zlib-ng's test suite would cause silent failures
  2. Library naming inconsistencies: Different zlib-ng configurations produce different library names (libz.a, libzlib.a, or libz-ng.a), but the build script always tried to link with zlib
  3. Test compilation issues: Building all targets included problematic test code that failed on some zlib-ng versions

Changes Made

Enhanced error handling: Added proper error checking for both CMake configure and build steps with descriptive panic messages to help diagnose issues.

Dynamic library detection: The build script now automatically detects which zlib library was actually built and links appropriately:

// Check for different possible library names
let possible_libs = ["libz.a", "libzlib.a", "libz-ng.a"];
// ... detect and link with the correct one

Target-specific builds: Only build the zlib target to avoid test compilation failures that can prevent library creation.

Improved Mac support: Explicitly force static builds and ensure proper architecture flags are set for both Intel and Apple Silicon Macs.

The fix makes the build process robust across different platforms and zlib-ng configurations, ensuring that the "could not find native static library" error is resolved by adapting to whatever library is actually produced.

Fixes #12.


✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.

Copy link
Copy Markdown
Author

Copilot AI commented Sep 14, 2025

@NiceneNerd 👋 This repository doesn't have Copilot instructions. With Copilot instructions, I can understand the repository better, work faster and produce higher quality PRs.

I can generate a .github/copilot-instructions.md file for you automatically. Click here to open a pre-filled issue and assign it to me. I'll write the instructions, and then tag you for review.

Co-authored-by: NiceneNerd <6720029+NiceneNerd@users.noreply.github.com>
Copilot AI changed the title [WIP] Build on Mac fails finding static zlib Fix Mac build failure with zlib static library detection Sep 14, 2025
Copilot AI requested a review from NiceneNerd September 14, 2025 21:29
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.

Build on Mac fails finding static zlib

2 participants