Skip to content

Link Android libc++ explicitly#9590

Open
sorinc03 wants to merge 1 commit into
software-mansion:mainfrom
sorinc03:fix/android-link-libcxx-shared
Open

Link Android libc++ explicitly#9590
sorinc03 wants to merge 1 commit into
software-mansion:mainfrom
sorinc03:fix/android-link-libcxx-shared

Conversation

@sorinc03

@sorinc03 sorinc03 commented Jun 2, 2026

Copy link
Copy Markdown

Summary

Fixes #9444.

This explicitly links c++_shared into both Android native targets so NDK 27 builds include -lc++_shared even when CMake leaves ANDROID_STL as an unconsumed cache variable.

Test plan

Ran the fabric example native debug build with the repo-configured NDK 27.1.12297006:

apps/fabric-example/android/gradlew -p apps/fabric-example/android :react-native-reanimated:externalNativeBuildDebug

The build completed successfully for react-native-worklets and react-native-reanimated across arm64-v8a, armeabi-v7a, x86, and x86_64. Generated Ninja files include -lc++_shared in both targets while CMakeCache.txt still shows ANDROID_STL:UNINITIALIZED=c++_shared, matching the issue scenario.

Also ran:

git diff --check

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes Android NDK 27.x linker failures by explicitly linking c++_shared in the native CMake targets for both react-native-worklets and react-native-reanimated, ensuring libc++ is linked even when ANDROID_STL is passed but not consumed by the NDK toolchain.

Changes:

  • Link c++_shared explicitly in react-native-worklets Android CMake target.
  • Link c++_shared explicitly in react-native-reanimated Android CMake target.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
packages/react-native-worklets/android/CMakeLists.txt Adds c++_shared to worklets target link libraries to force libc++ shared linkage on NDK 27.
packages/react-native-reanimated/android/CMakeLists.txt Adds c++_shared to reanimated target link libraries to force libc++ shared linkage on NDK 27.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@MatiPl01 MatiPl01 requested review from tjzel and tomekzaw June 4, 2026 06:07
@sorinc03

sorinc03 commented Jun 4, 2026

Copy link
Copy Markdown
Author

The two failing metadata checks look permission-related rather than code-related on this fork PR:

  • github-pull-request-description-format failed with Resource not accessible by integration while trying to append PR body content. The PR body already contains the template HTML comment now.
  • github-pull-request-label-format failed with Resource not accessible by integration while trying to add labels. I tried adding lib: Reanimated and lib: Worklets manually, but GitHub denied AddLabelsToLabelable for my account.

@tjzel

tjzel commented Jun 5, 2026

Copy link
Copy Markdown
Collaborator

Hi @sorinc03, thanks for the PR. The fix looks good to me but I don't understand one thing - why is the explicit linking statement required in our CMakeLists.txt but not in React Native's React Android? https://github.com/facebook/react-native/blob/main/packages/react-native/ReactAndroid/src/main/jni/CMakeLists.txt#L261-L271

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.

Android build fails on RN 0.82.1 + NDK 27.1: ANDROID_STL=c++_shared not consumed, libc++_shared not linked

3 participants