software-mansion / react-native-reanimated

React Native's Animated library reimplemented
https://docs.swmansion.com/react-native-reanimated/
MIT License
8.61k stars 1.26k forks source link

[CXX1429] error when building with cmake using #4971

Closed sebasg0 closed 1 week ago

sebasg0 commented 10 months ago

Description

[CXX1429] error when building with cmake using /Users/sebastiangarcia/Desktop/work/flm/this/AwesomeProject/node_modules/react-native-reanimated/android/CMakeLists.txt: -- Android: Targeting API '21' with architecture 'arm64', ABI 'arm64-v8a', and processor 'aarch64' -- Android: Selected unified Clang toolchain -- The C compiler identification is Clang 12.0.8 -- The CXX compiler identification is Clang 12.0.8 -- Detecting C compiler ABI info -- Detecting C compiler ABI info - failed -- Check for working C compiler: /Users/sebastiangarcia/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang -- Check for working C compiler: /Users/sebastiangarcia/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang - broken -- Configuring incomplete, errors occurred! See also "/Users/sebastiangarcia/Desktop/work/flm/this/AwesomeProject/node_modules/react-native-reanimated/android/.cxx/Debug/2m5o5448/arm64-v8a/CMakeFiles/CMakeOutput.log". See also "/Users/sebastiangarcia/Desktop/work/flm/this/AwesomeProject/node_modules/react-native-reanimated/android/.cxx/Debug/2m5o5448/arm64-v8a/CMakeFiles/CMakeError.log".

C++ build system [configure] failed while executing: /Users/sebastiangarcia/Library/Android/sdk/cmake/3.22.1/bin/cmake \ -H/Users/sebastiangarcia/Desktop/work/flm/this/AwesomeProject/node_modules/react-native-reanimated/android \ -DCMAKE_SYSTEM_NAME=Android \ -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \ -DCMAKE_SYSTEM_VERSION=21 \ -DANDROID_PLATFORM=android-21 \ -DANDROID_ABI=arm64-v8a \ -DCMAKE_ANDROID_ARCH_ABI=arm64-v8a \ -DANDROID_NDK=/Users/sebastiangarcia/Library/Android/sdk/ndk/23.1.7779620 \ -DCMAKE_ANDROID_NDK=/Users/sebastiangarcia/Library/Android/sdk/ndk/23.1.7779620 \ -DCMAKE_TOOLCHAIN_FILE=/Users/sebastiangarcia/Library/Android/sdk/ndk/23.1.7779620/build/cmake/android.toolchain.cmake \ -DCMAKE_MAKE_PROGRAM=/Users/sebastiangarcia/Library/Android/sdk/cmake/3.22.1/bin/ninja \ -DCMAKE_LIBRARY_OUTPUT_DIRECTORY=/Users/sebastiangarcia/Desktop/work/flm/this/AwesomeProject/node_modules/react-native-reanimated/android/build/intermediates/cxx/Debug/2m5o5448/obj/arm64-v8a \ -DCMAKE_RUNTIME_OUTPUT_DIRECTORY=/Users/sebastiangarcia/Desktop/work/flm/this/AwesomeProject/node_modules/react-native-reanimated/android/build/intermediates/cxx/Debug/2m5o5448/obj/arm64-v8a \ -DCMAKE_BUILD_TYPE=Debug \ -DCMAKE_FIND_ROOT_PATH=/Users/sebastiangarcia/Desktop/work/flm/this/AwesomeProject/node_modules/react-native-reanimated/android/.cxx/Debug/2m5o5448/prefab/arm64-v8a/prefab \ -B/Users/sebastiangarcia/Desktop/work/flm/this/AwesomeProject/node_modules/react-native-reanimated/android/.cxx/Debug/2m5o5448/arm64-v8a \ -GNinja \ -DANDROID_STL=c++_shared \ -DREACT_NATIVE_MINOR_VERSION=72 \ -DANDROID_TOOLCHAIN=clang \ -DCMAKE_C_FLAGS=-march=armv8-a \ -DCMAKE_CXX_FLAGS=-march=armv8-a \ -DCMAKE_EXE_LINKER_FLAGS=-Wl,--no-dead-strip-dylibs \ -DREACT_NATIVE_DIR=/Users/sebastiangarcia/Desktop/work/flm/this/AwesomeProject/node_modules/react-native \ -DJS_RUNTIME=hermes \ -DJS_RUNTIME_DIR=/Users/sebastiangarcia/Desktop/work/flm/this/AwesomeProject/node_modules/react-native/sdks/hermes \ -DCLIENT_SIDE_BUILD=true \ -DIS_NEW_ARCHITECTURE_ENABLED=false \ -DIS_REANIMATED_EXAMPLE_APP=false \ -DPLAYGROUND_APP_NAME=AwesomeProject \ -DREANIMATED_PACKAGE_BUILD=null \ -DREANIMATED_VERSION=3.4.2 \ -DHERMES_ENABLE_DEBUGGER=1 from /Users/sebastiangarcia/Desktop/work/flm/this/AwesomeProject/node_modules/react-native-reanimated/android CMake Error at /Users/sebastiangarcia/Library/Android/sdk/cmake/3.22.1/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message): Change Dir: /Users/sebastiangarcia/Desktop/work/flm/this/AwesomeProject/node_modules/react-native-reanimated/android/.cxx/Debug/2m5o5448/arm64-v8a/CMakeFiles/CMakeTmp

Run Build Command(s):/Users/sebastiangarcia/Library/Android/sdk/cmake/3.22.1/bin/ninja cmTC_7cd0f && [1/2] Building C object CMakeFiles/cmTC_7cd0f.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_7cd0f
FAILED: cmTC_7cd0f 
: && /Users/sebastiangarcia/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang --target=aarch64-none-linux-android21 --sysroot=/Users/sebastiangarcia/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -march=armv8-a  -O2 -g -DNDEBUG -Wl,--no-dead-strip-dylibs CMakeFiles/cmTC_7cd0f.dir/testCCompiler.c.o -o cmTC_7cd0f  -latomic -lm && :
ld: error: unknown argument '--no-dead-strip-dylibs'
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

"/Users/sebastiangarcia/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: /Users/sebastiangarcia/Desktop/work/flm/this/AwesomeProject/node_modules/react-native-reanimated/android/.cxx/Debug/2m5o5448/arm64-v8a/CMakeFiles/CMakeTmp

Run Build Command(s):/Users/sebastiangarcia/Library/Android/sdk/cmake/3.22.1/bin/ninja cmTC_7cd0f && [1/2] Building C object CMakeFiles/cmTC_7cd0f.dir/testCCompiler.c.o
[2/2] Linking C executable cmTC_7cd0f
FAILED: cmTC_7cd0f 
: && /Users/sebastiangarcia/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/bin/clang --target=aarch64-none-linux-android21 --sysroot=/Users/sebastiangarcia/Library/Android/sdk/ndk/23.1.7779620/toolchains/llvm/prebuilt/darwin-x86_64/sysroot -march=armv8-a  -O2 -g -DNDEBUG -Wl,--no-dead-strip-dylibs CMakeFiles/cmTC_7cd0f.dir/testCCompiler.c.o -o cmTC_7cd0f  -latomic -lm && :
ld: error: unknown argument '--no-dead-strip-dylibs'
clang-12: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

CMake will not be able to correctly generate this project. Call Stack (most recent call first): CMakeLists.txt:1 (project)

Steps to reproduce

  1. Create a new project with latest RN version
  2. install reanimated
  3. run build in android
  4. observe compilation issue

Snack or a link to a repository

https://github.com/software-mansion/react-native-reanimated/

Reanimated version

3.4.2

React Native version

0.72.4

Platforms

Android

JavaScript runtime

None

Workflow

None

Architecture

Paper (Old Architecture)

Build type

None

Device

None

Device model

No response

Acknowledgements

Yes

github-actions[bot] commented 10 months ago

Hey! 👋

The issue doesn't seem to contain a minimal reproduction.

Could you provide a snack or a link to a GitHub repository under your username that reproduces the problem?

sebasg0 commented 10 months ago

I'm on an m1 chip with macos Ventura 13.5.1 (22G90)

manoj-createBytes commented 10 months ago

Any update on this, I am also facing this issue

nth-zik commented 10 months ago

THe same on me, only work when use sudo

piaskowyk commented 10 months ago

Hey 👋 First thing: Could you provide a reproduction of your issue? Second thing: Do you have installed Rosetta on your computer?

nth-zik commented 10 months ago

First thing: Fail when I init new project too, just use react native init with template typescript Second thing: yes. The library will work fine if I run

sudo yarn android

Work well for iOS

a-tokyo commented 10 months ago

I'm still facing the same issue with rn 0.72.4

anopaishemeki commented 10 months ago

I'm am also facing the same issue with rn 0.72.4

On windows 11 core i7 8th gen

a-tokyo commented 10 months ago

I solved this issue by installing ninja-build using sudo apt-get ninja-build

We use CircleCI and RN 0.72.4

I am not sure if this solution will work for everyone, but it's worth a try. It will solve the issue if: ninja is missing or outdadted

nth-zik commented 10 months ago

`ninja: build stopped: subcommand failed.

C++ build system [build] failed while executing: /Users/hung/Library/Android/sdk/cmake/3.22.1/bin/ninja \ -C \ /Users/hung/Code/pm-apartment/pma/node_modules/react-native-reanimated/android/.cxx/Debug/5y2j84a3/arm64-v8a \ reanimated from /Users/hung/Code/pm-apartment/pma/node_modules/react-native-reanimated/android`

This is my stack trace.

Note: run success when use sudo

Andres0101 commented 9 months ago

I'm having the same [CXX1429] issue in windows. And I notice that it happends due to the Android Gradle plugin version in my project. Reanimated version 3.4.2

React Native version 0.68.2

android/build.gradle

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 21
        compileSdkVersion = 33
        targetSdkVersion = 33
        ndkVersion = '23.1.7779620'
        kotlinVersion = '1.6.21'
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.0'
        classpath 'com.google.gms:google-services:4.3.14'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
    }
}

If I change to com.android.tools.build:gradle:7.0.4 it works fine but I need the update to 7.4.0 so that my application targets Android 13, requirement by google play store. Any solution ?

PS: I even try with the lastest version, at the moment, of react-native-reanimated 3.5.4 and it does not build, get the same [CXX1429] error

dilawer-dev commented 9 months ago

I am facing the same issue any help will be appreciated

Sergiohcp commented 9 months ago

I am facing the same issue too, and I need deploy our .aab file with fastlane.

Did anyone get any fixes?

buuhvprojects commented 9 months ago

On android studio you need to install CMake

Sergiohcp commented 9 months ago

On android studio you need to install CMake

So, currently I am using bitrise with fastlane to deploy .aab direct to google play console.

The problem occurs in build phase (gradle) of fastlane.

sidm033 commented 8 months ago

fix this problem you have to set a Kotlin version on your project-level build grade android/build.gradle for example:

buildscript {
    ext {
        // ...
        kotlin_version = '1.6.10' // <- add this line
    }

    dependencies {
        // ...
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // <- add this line
        // ...
    }
}
nth-zik commented 8 months ago

I solve this issue by add SUDO to command sudo yarn run android On MacOS 14

usmanabid94 commented 8 months ago

I ama facing the same issue on 0.72.6 with react native reanimated version 3.5.4? This is the error message from android studio: from /Users/apple/Desktop/projectpath/node_modules/react-native-reanimated/android CMake Error at CMakeLists.txt:48 (find_package): Could not find a package configuration file provided by "fbjni" with any of the following names:

fbjniConfig.cmake
fbjni-config.cmake

Add the installation prefix of "fbjni" to CMAKE_PREFIX_PATH or set "fbjni_DIR" to a directory containing one of the above files. If "fbjni" provides a separate development package or SDK, be sure it has been installed.

BichThien commented 8 months ago

i fixed it by follow this guide but after a while, when i opened the project and build again, i faced it again and now have no clue to fix it. https://github.com/KhronosGroup/OpenXR-SDK-Source/blob/main/BUILDING.md

usmanabid94 commented 8 months ago

@BichThien i am facing this issue as i have updated my react native project form 0.66 to 0.72.6 version the issue mentioned appears on the react native version when buidling the app for android app only the IOS app compiles fine this issue only appears in android studio when the project is being synced or being build. node_modules/react-native-reanimated/android CMake Error at CMakeLists.txt:48 (find_package): Could not find a package configuration file provided by "fbjni" with any of the following names:

fbjniConfig.cmake fbjni-config.cmake Add the installation prefix of "fbjni" to CMAKE_PREFIX_PATH or set "fbjni_DIR" to a directory containing one of the above files. If "fbjni" provides a separate development package or SDK, be sure it has been installed.

Digital-Human-BK commented 7 months ago

Any update I've been trying to solve the issue for the last 2 days but no luck so far... React-native v0.72.6 with react-native-reanimated v3.5.4 and CMake 3.22.1 installed

This is the actual error message: `FAILURE: Build failed with an exception.

What went wrong: Execution failed for task ':react-native-reanimated:configureCMakeDebug[arm64-v8a]'. [CXX1429] error when building with cmake using D:\Coding\React-Native-Projects\MyProject\node_modules\react-native-reanimated\android\CMakeLists.txt: C++ build system [configure] failed while executing: @echo off "C:\Users\user\AppData\Local\Android\Sdk\cmake\3.22.1\bin\cmake.exe" ^ "-HD:\Coding\React-Native-Projects\MyProject\node_modules\react-native-reanimated\android" ^ "-DCMAKE_SYSTEM_NAME=Android" ^ "-DCMAKE_EXPORT_COMPILE_COMMANDS=ON" ^ "-DCMAKE_SYSTEM_VERSION=21" ^ "-DANDROID_PLATFORM=android-21" ^ "-DANDROID_ABI=arm64-v8a" ^ "-DCMAKE_ANDROID_ARCH_ABI=arm64-v8a" ^`

BichThien commented 7 months ago

@Digital-Human-BK, I figure out that Cmake ver 3.22.1 is error, the simple solution to fix it is make the version down, 3.10.3 fine to work.

Digital-Human-BK commented 7 months ago

I finally managed to get it working. It turned out to be the JDK version in my case. I was with version 11.0.18 (RN Docs recommend JDK11 for development).

A simple update to JDK version 11.0.20 solved all the problems.

usmanabid94 commented 7 months ago

@BichThien i am facing this issue as i have updated my react native project form 0.66 to 0.72.6 version the issue mentioned appears on the react native version when buidling the app for android app only the IOS app compiles fine this issue only appears in android studio when the project is being synced or being build. node_modules/react-native-reanimated/android CMake Error at CMakeLists.txt:48 (find_package): Could not find a package configuration file provided by "fbjni" with any of the following names:

fbjniConfig.cmake fbjni-config.cmake Add the installation prefix of "fbjni" to CMAKE_PREFIX_PATH or set "fbjni_DIR" to a directory containing one of the above files. If "fbjni" provides a separate development package or SDK, be sure it has been installed.

@Digital-Human-BK @BichThien I was facing this isssue but i have deleted the android folder and created it again and then the dependencies were installed correctly i guess it has something to do wiht the latest version of react native with the android project of react native by using the command mentioned and turns out that the things are working fine till now: npx react-native eject

Shahzaib114 commented 7 months ago

if you have tried all the possible solutions ad still facing CXX[1429] or CXX[1405] for cMake

Make Sure to following C++ extensions in visual studio code C/C++ C/C++ Theme C/C++ Extensions Pack CMake CMake Tools Gradle for Java

Main Thing, install "Visual C++ Redistributable for Visual Studio 2015" from the following link: https://www.microsoft.com/en-us/download/confirmation.aspx?id=48145&6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1

Restart your vs code or your System

GaboRocker1992 commented 6 months ago

It's funny and absurd, but the issue is due to the project path being too long. I recommend copying or moving your project to c:\ or desktop. Delete the node_modules folder, run npm i, cd android & ./gradlew clean, and then build.

RONAKDHOLARIYA commented 6 months ago

if you have tried all the possible solutions ad still facing CXX[1429] or CXX[1405] for cMake, it's because you do not have C++ configurations in project. For that follow below instructions

Make Sure to following C++ extensions in visual studio code C/C++ C/C++ Theme C/C++ Extensions Pack CMake CMake Tools Gradle for Java

Main Thing, install "Visual C++ Redistributable for Visual Studio 2015" from the following link: https://www.microsoft.com/en-us/download/confirmation.aspx?id=48145&6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1

Restart your vs code or your System

This thing resolve my issue in windows pc

Thanks @Shahzaib114

david10191 commented 6 months ago

if you have tried all the possible solutions ad still facing CXX[1429] or CXX[1405] for cMake

Make Sure to following C++ extensions in visual studio code C/C++ C/C++ Theme C/C++ Extensions Pack CMake CMake Tools Gradle for Java

Main Thing, install "Visual C++ Redistributable for Visual Studio 2015" from the following link: https://www.microsoft.com/en-us/download/confirmation.aspx?id=48145&6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1

Restart your vs code or your System

Just downloaded this, and it worked like magic. Thanks

MasterAlex233 commented 6 months ago

if you have tried all the possible solutions ad still facing CXX[1429] or CXX[1405] for cMake

Make Sure to following C++ extensions in visual studio code C/C++ C/C++ Theme C/C++ Extensions Pack CMake CMake Tools Gradle for Java

Main Thing, install "Visual C++ Redistributable for Visual Studio 2015" from the following link: https://www.microsoft.com/en-us/download/confirmation.aspx?id=48145&6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1

Restart your vs code or your System

Thank you for being my savior

amitjha329 commented 5 months ago

if you have tried all the possible solutions ad still facing CXX[1429] or CXX[1405] for cMake

Make Sure to following C++ extensions in visual studio code C/C++ C/C++ Theme C/C++ Extensions Pack CMake CMake Tools Gradle for Java

Main Thing, install "Visual C++ Redistributable for Visual Studio 2015" from the following link: https://www.microsoft.com/en-us/download/confirmation.aspx?id=48145&6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1

Restart your vs code or your System

installing "Visual C++ Redistributable for Visual Studio 2015" seems to be the main issue for my Windows 11 system.

Thomas-Vargas commented 5 months ago

if you have tried all the possible solutions ad still facing CXX[1429] or CXX[1405] for cMake

Make Sure to following C++ extensions in visual studio code C/C++ C/C++ Theme C/C++ Extensions Pack CMake CMake Tools Gradle for Java

Main Thing, install "Visual C++ Redistributable for Visual Studio 2015" from the following link: https://www.microsoft.com/en-us/download/confirmation.aspx?id=48145&6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1

Restart your vs code or your System

This solved my issues on windows 11 machine as well, Thank you!

AKP-007-Anil-Kumar-Prajapat commented 4 months ago

It's funny and absurd, but the issue is due to the project path being too long. I recommend copying or moving your project to c:\ or desktop. Delete the node_modules folder, run npm i, cd android & ./gradlew clean, and then build.

it's working

neilanthonyte commented 4 months ago

I solve this issue by add SUDO to command sudo yarn run android On MacOS 14

for some weird reason the error was gone after running react native with sudo

lavisar commented 3 months ago

if you have tried all the possible solutions ad still facing CXX[1429] or CXX[1405] for cMake

Make Sure to following C++ extensions in visual studio code C/C++ C/C++ Theme C/C++ Extensions Pack CMake CMake Tools Gradle for Java

Main Thing, install "Visual C++ Redistributable for Visual Studio 2015" from the following link: https://www.microsoft.com/en-us/download/confirmation.aspx?id=48145&6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1

Restart your vs code or your System

Thank you so much, I've dowloaded it and it work!!!!

Ritikkk-09 commented 3 months ago

if you have tried all the possible solutions ad still facing CXX[1429] or CXX[1405] for cMake

Make Sure to following C++ extensions in visual studio code C/C++ C/C++ Theme C/C++ Extensions Pack CMake CMake Tools Gradle for Java

Main Thing, install "Visual C++ Redistributable for Visual Studio 2015" from the following link: https://www.microsoft.com/en-us/download/confirmation.aspx?id=48145&6B49FDFB-8E5B-4B07-BC31-15695C5A2143=1

Restart your vs code or your System

Thanks a lot, it work for react-native-reanimated and react-native-screens both library problem

itmsroohim commented 2 months ago

Whats the solution for Mac OS ?

usmanabid94 commented 2 months ago

@BichThien i am facing this issue as i have updated my react native project form 0.66 to 0.72.6 version the issue mentioned appears on the react native version when buidling the app for android app only the IOS app compiles fine this issue only appears in android studio when the project is being synced or being build. node_modules/react-native-reanimated/android CMake Error at CMakeLists.txt:48 (find_package): Could not find a package configuration file provided by "fbjni" with any of the following names: fbjniConfig.cmake fbjni-config.cmake Add the installation prefix of "fbjni" to CMAKE_PREFIX_PATH or set "fbjni_DIR" to a directory containing one of the above files. If "fbjni" provides a separate development package or SDK, be sure it has been installed.

@Digital-Human-BK @BichThien I was facing this isssue but i have deleted the android folder and created it again and then the dependencies were installed correctly i guess it has something to do wiht the latest version of react native with the android project of react native by using the command mentioned and turns out that the things are working fine till now: npx react-native eject

@itmsroohim I have fixed it on macOS by using these steps mentioned above and have done in multiple projects and on different react and react native versions and this has so far worked perfectly for me

ErAz7 commented 2 months ago

installing Visual C++ Redistributable for Visual Studio 2015 as suggested by @Shahzaib114 fixed the error Cheers @Shahzaib114 🥂 , saved my day

szydlovsky commented 1 week ago

Feels like most of you found your answers 😄 I'll close it now. If anyone still faces some issues (after trying aforementioned fixes) - make sure to open new issue cause this one is already really crowded

BlagojeV93 commented 2 days ago

fix this problem you have to set a Kotlin version on your project-level build grade android/build.gradle for example:

buildscript {
    ext {
        // ...
        kotlin_version = '1.6.10' // <- add this line
    }

    dependencies {
        // ...
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // <- add this line
        // ...
    }
}

My problem was solved just by adding the kotlin version below to the classpath line. Thanks! BTW I'm a mac user.