Skip to content

fix: link failure on macOS 15+ due to missing libpthread - #207

Open
BH3GEI wants to merge 1 commit into
symless:masterfrom
BH3GEI:fix/macos-pthread-link
Open

fix: link failure on macOS 15+ due to missing libpthread#207
BH3GEI wants to merge 1 commit into
symless:masterfrom
BH3GEI:fix/macos-pthread-link

Conversation

@BH3GEI

@BH3GEI BH3GEI commented Jun 16, 2026

Copy link
Copy Markdown

Summary

Building on macOS 15+ (Sequoia/Tahoe) with Xcode 16+ fails at link time:

ld: library 'pthread' not found

Modern macOS consolidates pthread into libSystem — there is no standalone libpthread to link against. The existing check_library_exists("pthread" ...) check passes (because pthread_create exists in libSystem), but the resulting -lpthread flag fails with the new linker.

Fix: On Apple platforms, use CMake's find_package(Threads) + Threads::Threads instead of raw -lpthread. This correctly resolves to the system threading support without requiring a standalone library. The HAVE_PTHREAD variable is still set so ArchMultithreadPosix.h is included as before. Linux/BSD path is unchanged.

Test plan

  • Build on macOS 26.2 (Tahoe) with Xcode 17 / Apple clang 17 — links successfully
  • HAVE_PTHREAD correctly defined, ArchMultithreadPosix compiles
  • No impact on non-Apple platforms (guarded by if(APPLE))

Modern macOS (15+) bundles pthread into libSystem with no separate
libpthread, so -lpthread fails at link time. Use find_package(Threads)
and Threads::Threads on Apple platforms while keeping the existing
check_library_exists path for Linux/BSD.
@nbolton

nbolton commented Jun 17, 2026

Copy link
Copy Markdown
Member

Thanks for the PR, I will review. Is this relevant to upstream Deskflow?

@sithlord48

Copy link
Copy Markdown
Contributor

It sure is. As we use the same logic to find pthread in Deskflow. This should be moved to the deskflow repo imho

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.

3 participants