Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cannot build from source on Android on Windows, CMake reporting "broken" compiler. #37770

Open
MO-Lewis opened this issue Jun 8, 2023 · 11 comments
Labels
Help Wanted :octocat: Issues ideal for external contributors. Never gets stale Prevent those issues and PRs from getting stale Platform: Android Android applications. Platform: Windows Building on Windows.

Comments

@MO-Lewis
Copy link
Contributor

MO-Lewis commented Jun 8, 2023

Description

Hi there,

For a project, we need to build React Native from source. This is required for us, as we need to apply the following fix to React Native, which was approved to merge into the main React Native repo, but was never merged due to React Native renaming the branch and accidentally scrapping the PR: #28659 (comment)

If the above issue could be picked up again and merged-in to the main repo (it was fully approved and ready to merge before the branch rename!), that would also be much appreciated!

I'm running on Windows 10 (Version 10.0.19045 Build 19045), and I'm having some difficulties trying to build a boilerplate React Native project, whilst building React Native from source. I've followed the steps described here: https://reactnative.dev/contributing/how-to-build-from-source

Due to running on Windows, I am unable to see if the issue also happens when running an iOS build.

However, when trying to run the Android build, I get an error from cmake at the :react-native:ReactAndroid:hermes-engine:configureBuildForHermes stage.

I'll provide the FULL command line output below.

If I undo the steps provided in the "build from source" link (Removing the extra lines from android/settings.gradle), then the build works, so I'm fairly sure something's going wrong when building from source for me. I'll provide images of my Android Studio settings (NDK, SDK, Build tool versions, etc.) below too.

If there's any other information you'd like from me / my environment, please let me know. Thanks!

React Native Version

0.71.8
Updated to 0.71.10

Output of npx react-native info

info Fetching system and libraries information...
System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 11th Gen Intel(R) Core(TM) i7-1165G7 @ 2.80GHz
    Memory: 16.20 GB / 39.69 GB
  Binaries:
    Node: 16.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.19 - C:\Program Files\nodejs\yarn.CMD
    npm: 8.15.0 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK:
      API Levels: 29, 31, 32, 33, 33
      Build Tools: 30.0.3, 31.0.0, 33.0.0
      System Images: android-31 | Google APIs Intel x86_64 Atom
      Android NDK: Not Found
    Windows SDK:
      AllowDevelopmentWithoutDevLicense: Enabled
      Versions: 10.0.20348.0, 10.0.22000.0
  IDEs:
    Android Studio: AI-222.4459.24.2221.9862592
    Visual Studio: 17.6.33723.286 (Visual Studio Community 2022)
  Languages:
    Java: Not Found
  npmPackages:
    @react-native-community/cli: Not Found
    react: 18.2.0 => 18.2.0
    react-native: 0.71.8 => 0.71.8
    react-native-windows: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

Steps to reproduce

  1. Create a boilerplate React Native app. (npx react-native init AwesomeProject)
  2. npm install, etc.
  3. Build once to ensure you've set everything up properly.
  4. Add the extra lines to your android/settings.gradle file, as required here: https://reactnative.dev/contributing/how-to-build-from-source
  5. Go into the android/ directory and run gradlew clean. Go up one level and reinstall your node_modules to ensure everything is fresh.
  6. After, initiate an Android build with npm run android
  7. This should now fail at the :react-native:ReactAndroid:hermes-engine:configureBuildForHermes stage, with a CMake error.

Snack, code example, screenshot, or link to a repository

Steps to reproduce the issue on a blank project are linked above.

Full command line output from npm run android:

PS C:\MYOXYGEN-REPOS\PERSONAL\cicdtest> npm run android

> [email protected] android
> react-native run-android

info Starting JS server...
info Installing the app...

> Task :react-native:ReactAndroid:hermes-engine:downloadHermes
Download https://github.com/facebook/hermes/tarball/hermes-2023-03-07-RNv0.71.4-31fdcf738940875c9bacf251e149006cf515d763

> Task :react-native:ReactAndroid:hermes-engine:configureBuildForHermes FAILED
-- The C compiler identification is MSVC 19.36.32532.0
-- The CXX compiler identification is MSVC 19.36.32532.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - failed
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe
-- Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe - broken
-- Configuring incomplete, errors occurred!
See also "C:/MYOXYGEN-REPOS/PERSONAL/cicdtest/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/CMakeFiles/CMakeOutput.log".
See also "C:/MYOXYGEN-REPOS/PERSONAL/cicdtest/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/CMakeFiles/CMakeError.log".
22 actionable tasks: 22 executed
CMake Deprecation Warning at CMakeLists.txt:42 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Error at C:/ANDROID_SDK/cmake/3.22.1/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/MYOXYGEN-REPOS/PERSONAL/cicdtest/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/CMakeFiles/CMakeTmp

    Run Build Command(s):nmake -f Makefile /nologo cmTC_ddf64\fast &&   "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\bin\Hostx64\x64\nmake.exe"  -f CMakeFiles\cmTC_ddf64.dir\build.make /nologo -L                  CMakeFiles\cmTC_ddf64.dir\build
    Building C object CMakeFiles/cmTC_ddf64.dir/testCCompiler.c.obj
        C:\ANDROID_SDK\cmake\3.22.1\bin\cmake.exe -E cmake_cl_compile_depends --dep-file=CMakeFiles\cmTC_ddf64.dir\testCCompiler.c.obj.d --working-dir=C:\MYOXYGEN-REPOS\PERSONAL\cicdtest\node_modules\react-native\ReactAndroid\hermes-engine\build\hermes\CMakeFiles\CMakeTmp --filter-prefix="Note: including file: " -- C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1436~1.325\bin\Hostx64\x64\cl.exe @C:\Users\LEWISK~1\AppData\Local\Temp\nmAD48.tmp
    testCCompiler.c
    Linking C executable cmTC_ddf64.exe
        C:\ANDROID_SDK\cmake\3.22.1\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_ddf64.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1436~1.325\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_ddf64.dir\objects1.rsp @C:\Users\LEWISK~1\AppData\Local\Temp\nmAD97.tmp
    RC Pass 1: command "rc /fo CMakeFiles\cmTC_ddf64.dir/manifest.res CMakeFiles\cmTC_ddf64.dir/manifest.rc" failed (exit code 0) with the following output:
    The system cannot find the file specifiedNMAKE : fatal error U1077: 'C:\ANDROID_SDK\cmake\3.22.1\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_ddf64.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1436~1.325\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_ddf64.dir\objects1.rsp @C:\Users\LEWISK~1\AppData\Local\Temp\nmAD97.tmp' : return code '0xffffffff'
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\bin\Hostx64\x64\nmake.exe"  -f CMakeFiles\cmTC_ddf64.dir\build.make /nologo -L                  CMakeFiles\cmTC_ddf64.dir\build' : return code '0x2'
    Stop.





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



FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native:ReactAndroid:hermes-engine:configureBuildForHermes'.
> Process 'command 'cmd'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 8s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081
CMake Deprecation Warning at CMakeLists.txt:42 (cmake_policy):
  The OLD behavior for policy CMP0026 will be removed from a future version
  of CMake.

  The cmake-policies(7) manual explains that the OLD behaviors of all
  policies are deprecated and that a policy should be set to OLD only under
  specific short-term circumstances.  Projects should be ported to the NEW
  behavior and not rely on setting a policy to OLD.


CMake Error at C:/ANDROID_SDK/cmake/3.22.1/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message):
  The C compiler

    "C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe"

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: C:/MYOXYGEN-REPOS/PERSONAL/cicdtest/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes/CMakeFiles/CMakeTmp

    Run Build Command(s):nmake -f Makefile /nologo cmTC_ddf64\fast &&   "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\bin\Hostx64\x64\nmake.exe"  -f CMakeFiles\cmTC_ddf64.dir\build.make /nologo -L                  CMakeFiles\cmTC_ddf64.dir\build
    Building C object CMakeFiles/cmTC_ddf64.dir/testCCompiler.c.obj
        C:\ANDROID_SDK\cmake\3.22.1\bin\cmake.exe -E cmake_cl_compile_depends --dep-file=CMakeFiles\cmTC_ddf64.dir\testCCompiler.c.obj.d --working-dir=C:\MYOXYGEN-REPOS\PERSONAL\cicdtest\node_modules\react-native\ReactAndroid\hermes-engine\build\hermes\CMakeFiles\CMakeTmp --filter-prefix="Note: including file: " -- C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1436~1.325\bin\Hostx64\x64\cl.exe @C:\Users\LEWISK~1\AppData\Local\Temp\nmAD48.tmp
    testCCompiler.c
    Linking C executable cmTC_ddf64.exe
        C:\ANDROID_SDK\cmake\3.22.1\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_ddf64.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1436~1.325\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_ddf64.dir\objects1.rsp @C:\Users\LEWISK~1\AppData\Local\Temp\nmAD97.tmp
    RC Pass 1: command "rc /fo CMakeFiles\cmTC_ddf64.dir/manifest.res CMakeFiles\cmTC_ddf64.dir/manifest.rc" failed (exit code 0) with the following output:
    The system cannot find the file specifiedNMAKE : fatal error U1077: 'C:\ANDROID_SDK\cmake\3.22.1\bin\cmake.exe -E vs_link_exe --intdir=CMakeFiles\cmTC_ddf64.dir --rc=rc --mt=CMAKE_MT-NOTFOUND --manifests -- C:\PROGRA~2\MICROS~2\2022\BUILDT~1\VC\Tools\MSVC\1436~1.325\bin\Hostx64\x64\link.exe /nologo @CMakeFiles\cmTC_ddf64.dir\objects1.rsp @C:\Users\LEWISK~1\AppData\Local\Temp\nmAD97.tmp' : return code '0xffffffff'
    Stop.
    NMAKE : fatal error U1077: '"C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.36.32532\bin\Hostx64\x64\nmake.exe"  -f CMakeFiles\cmTC_ddf64.dir\build.make /nologo -L                  CMakeFiles\cmTC_ddf64.dir\build' : return code '0x2'
    Stop.





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



FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native:ReactAndroid:hermes-engine:configureBuildForHermes'.
> Process 'command 'cmd'' finished with non-zero exit value 1

* Try:
> Run with --stacktrace option to get the stack trace.
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2m 8s

    at makeError (C:\MYOXYGEN-REPOS\PERSONAL\cicdtest\node_modules\execa\index.js:174:9)
    at C:\MYOXYGEN-REPOS\PERSONAL\cicdtest\node_modules\execa\index.js:278:16
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async runOnAllDevices (C:\MYOXYGEN-REPOS\PERSONAL\cicdtest\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:82:7)
    at async Command.handleAction (C:\MYOXYGEN-REPOS\PERSONAL\cicdtest\node_modules\@react-native-community\cli\build\index.js:108:9)
info Run CLI with --verbose flag for more details.

Installed Android Studio Tools:

image
image

Installed Visual Studio Tools:

image
image

@github-actions
Copy link

github-actions bot commented Jun 8, 2023

⚠️ Newer Version of React Native is Available!
ℹ️ You are on a supported minor version, but it looks like there's a newer patch available - 0.71.10. Please upgrade to the highest patch for your minor or latest and verify if the issue persists (alternatively, create a new project and repro the issue in it). If it does not repro, please let us know so we can close out this issue. This helps us ensure we are looking at issues that still exist in the most recent releases.

@github-actions github-actions bot added the Platform: Android Android applications. label Jun 8, 2023
@MO-Lewis
Copy link
Contributor Author

MO-Lewis commented Jun 8, 2023

Still an issue on 0.71.10, I'll edit the issue with the new RN version; everything previously mentioned in the report still applies.

@cortinico
Copy link
Contributor

For a client's project, we need to build React Native from source. This is required for us, as we need to apply the following fix to React Native, which was approved to merge into the main React Native repo, but was never merged due to React Native renaming the branch and accidentally scrapping the PR: #28659 (comment)

Please open a new PR with the same code and we can look into it/get it merged.

As for the build from source on Windows, that's sadly more complicated that expected as most of our builds are on MacOS or Linux. We would need someone from Microsoft to take a look at this ideally.

@MO-Lewis
Copy link
Contributor Author

MO-Lewis commented Jun 9, 2023

I've added a bit more info to this in the duplicate issue mentioned above: #37780 (comment)

Additionally, I've undone the initial commit that was done by @mganandraj, so we don't use nmake when building from Windows, but then this leads me to the error that this guy is getting here: software-mansion/react-native-reanimated#3594 (comment)

Different repo, but it's still an error that's produced by trying to build the hermes error from source on a Windows machine. As additional info, I do not have the newArchEnabled flag set to true.

As stated in the other issue ticket, the ideal scenario would be to get mganandraj in on this issue, so we can see how Windows is building RN on his machine.

I've gone into the CMake cache file within the downloaded copy of hermes-engine (.\React-Project-Root\node_modules\react-native\ReactAndroid\hermes-engine\build\hermes\CMakeCache.txt) to see what variables it resolves and where, and I get the following info. I'd be interested to see what mganandraj's copy of this looks like.

# This is the CMakeCache file.
# For build in directory: c:/MYOXYGEN-REPOS/PERSONAL/cicdtest/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes
# It was generated by CMake: C:/ANDROID_SDK/cmake/3.22.1/bin/cmake.exe
# You can edit this file to change values found and used by cmake.
# If you do not want to change any of the values, simply exit the editor.
# If you do want to change a value, simply edit, save, and exit the editor.
# The syntax for the file is as follows:
# KEY:TYPE=VALUE
# KEY is the name of a variable in the cache.
# TYPE is a hint to GUIs for the type of VALUE, DO NOT EDIT TYPE!.
# VALUE is the current value for the KEY.

########################
# EXTERNAL cache entries
########################

//Path to a program.
CMAKE_AR:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/lib.exe

//Choose the type of build, options are: None Debug Release RelWithDebInfo
// MinSizeRel ...
CMAKE_BUILD_TYPE:STRING=Debug

//Enable/Disable color output during build.
CMAKE_COLOR_MAKEFILE:BOOL=ON

//CXX compiler
CMAKE_CXX_COMPILER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe

//C compiler
CMAKE_C_COMPILER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/cl.exe

//Flags used by the C compiler during all build types.
CMAKE_C_FLAGS:STRING=/DWIN32 /D_WINDOWS /W3

//Flags used by the C compiler during DEBUG builds.
CMAKE_C_FLAGS_DEBUG:STRING=/MDd /Zi /Ob0 /Od /RTC1

//Flags used by the C compiler during MINSIZEREL builds.
CMAKE_C_FLAGS_MINSIZEREL:STRING=/MD /O1 /Ob1 /DNDEBUG

//Flags used by the C compiler during RELEASE builds.
CMAKE_C_FLAGS_RELEASE:STRING=/MD /O2 /Ob2 /DNDEBUG

//Flags used by the C compiler during RELWITHDEBINFO builds.
CMAKE_C_FLAGS_RELWITHDEBINFO:STRING=/MD /Zi /O2 /Ob1 /DNDEBUG

//Libraries linked by default with all C applications.
CMAKE_C_STANDARD_LIBRARIES:STRING=kernel32.lib user32.lib gdi32.lib winspool.lib shell32.lib ole32.lib oleaut32.lib uuid.lib comdlg32.lib advapi32.lib

//Flags used by the linker during all build types.
CMAKE_EXE_LINKER_FLAGS:STRING=/machine:x64

//Flags used by the linker during DEBUG builds.
CMAKE_EXE_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL

//Flags used by the linker during MINSIZEREL builds.
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO

//Flags used by the linker during RELEASE builds.
CMAKE_EXE_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO

//Flags used by the linker during RELWITHDEBINFO builds.
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL

//Install path prefix, prepended onto install directories.
CMAKE_INSTALL_PREFIX:PATH=C:/Program Files (x86)/Hermes

//Path to a program.
CMAKE_LINKER:FILEPATH=C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.36.32532/bin/Hostx64/x64/link.exe

//Program used to build from makefiles.
CMAKE_MAKE_PROGRAM:STRING=nmake

//Flags used by the linker during the creation of modules during
// all build types.
CMAKE_MODULE_LINKER_FLAGS:STRING=/machine:x64

//Flags used by the linker during the creation of modules during
// DEBUG builds.
CMAKE_MODULE_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL

//Flags used by the linker during the creation of modules during
// MINSIZEREL builds.
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO

//Flags used by the linker during the creation of modules during
// RELEASE builds.
CMAKE_MODULE_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO

//Flags used by the linker during the creation of modules during
// RELWITHDEBINFO builds.
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL

//Path to a program.
CMAKE_MT:FILEPATH=C:/Program Files (x86)/Windows Kits/10/bin/10.0.22000.0/x86/mt.exe

//Value Computed by CMake
CMAKE_PROJECT_DESCRIPTION:STATIC=

//Value Computed by CMake
CMAKE_PROJECT_HOMEPAGE_URL:STATIC=

//Value Computed by CMake
CMAKE_PROJECT_NAME:STATIC=Hermes

//Value Computed by CMake
CMAKE_PROJECT_VERSION:STATIC=0.12.0

//Value Computed by CMake
CMAKE_PROJECT_VERSION_MAJOR:STATIC=0

//Value Computed by CMake
CMAKE_PROJECT_VERSION_MINOR:STATIC=12

//Value Computed by CMake
CMAKE_PROJECT_VERSION_PATCH:STATIC=0

//Value Computed by CMake
CMAKE_PROJECT_VERSION_TWEAK:STATIC=

//RC compiler
CMAKE_RC_COMPILER:FILEPATH=C:/Program Files (x86)/Windows Kits/10/bin/10.0.22000.0/x86/rc.exe

//Flags for Windows Resource Compiler during all build types.
CMAKE_RC_FLAGS:STRING=-DWIN32

//Flags for Windows Resource Compiler during DEBUG builds.
CMAKE_RC_FLAGS_DEBUG:STRING=-D_DEBUG

//Flags for Windows Resource Compiler during MINSIZEREL builds.
CMAKE_RC_FLAGS_MINSIZEREL:STRING=

//Flags for Windows Resource Compiler during RELEASE builds.
CMAKE_RC_FLAGS_RELEASE:STRING=

//Flags for Windows Resource Compiler during RELWITHDEBINFO builds.
CMAKE_RC_FLAGS_RELWITHDEBINFO:STRING=

//Flags used by the linker during the creation of shared libraries
// during all build types.
CMAKE_SHARED_LINKER_FLAGS:STRING=/machine:x64

//Flags used by the linker during the creation of shared libraries
// during DEBUG builds.
CMAKE_SHARED_LINKER_FLAGS_DEBUG:STRING=/debug /INCREMENTAL

//Flags used by the linker during the creation of shared libraries
// during MINSIZEREL builds.
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL:STRING=/INCREMENTAL:NO

//Flags used by the linker during the creation of shared libraries
// during RELEASE builds.
CMAKE_SHARED_LINKER_FLAGS_RELEASE:STRING=/INCREMENTAL:NO

//Flags used by the linker during the creation of shared libraries
// during RELWITHDEBINFO builds.
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO:STRING=/debug /INCREMENTAL

//If set, runtime paths are not added when installing shared libraries,
// but are added when building.
CMAKE_SKIP_INSTALL_RPATH:BOOL=NO

//If set, runtime paths are not added when using shared libraries.
CMAKE_SKIP_RPATH:BOOL=NO

//Flags used by the linker during the creation of static libraries
// during all build types.
CMAKE_STATIC_LINKER_FLAGS:STRING=/machine:x64

//Flags used by the linker during the creation of static libraries
// during DEBUG builds.
CMAKE_STATIC_LINKER_FLAGS_DEBUG:STRING=

//Flags used by the linker during the creation of static libraries
// during MINSIZEREL builds.
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL:STRING=

//Flags used by the linker during the creation of static libraries
// during RELEASE builds.
CMAKE_STATIC_LINKER_FLAGS_RELEASE:STRING=

//Flags used by the linker during the creation of static libraries
// during RELWITHDEBINFO builds.
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO:STRING=

//If this value is on, makefiles will be generated without the
// .SILENT directive, and all commands will be echoed to the console
// during the make.  This is useful for debugging only. With Visual
// Studio IDE projects all commands are done without /nologo.
CMAKE_VERBOSE_MAKEFILE:BOOL=FALSE

//Value Computed by CMake
Hermes_BINARY_DIR:STATIC=C:/MYOXYGEN-REPOS/PERSONAL/cicdtest/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes

//Value Computed by CMake
Hermes_IS_TOP_LEVEL:STATIC=ON

//Value Computed by CMake
Hermes_SOURCE_DIR:STATIC=C:/MYOXYGEN-REPOS/PERSONAL/cicdtest/node_modules/react-native/sdks/hermes

//No help, variable specified on the command line.
JSI_DIR:UNINITIALIZED=C:\MYOXYGEN-REPOS\PERSONAL\cicdtest\node_modules\react-native\ReactCommon\jsi


########################
# INTERNAL cache entries
########################

//ADVANCED property for variable: CMAKE_AR
CMAKE_AR-ADVANCED:INTERNAL=1
//This is the directory where this CMakeCache.txt was created
CMAKE_CACHEFILE_DIR:INTERNAL=c:/MYOXYGEN-REPOS/PERSONAL/cicdtest/node_modules/react-native/ReactAndroid/hermes-engine/build/hermes
//Major version of cmake used to create the current loaded cache
CMAKE_CACHE_MAJOR_VERSION:INTERNAL=3
//Minor version of cmake used to create the current loaded cache
CMAKE_CACHE_MINOR_VERSION:INTERNAL=22
//Patch version of cmake used to create the current loaded cache
CMAKE_CACHE_PATCH_VERSION:INTERNAL=1
//ADVANCED property for variable: CMAKE_COLOR_MAKEFILE
CMAKE_COLOR_MAKEFILE-ADVANCED:INTERNAL=1
//Path to CMake executable.
CMAKE_COMMAND:INTERNAL=C:/ANDROID_SDK/cmake/3.22.1/bin/cmake.exe
//Path to cpack program executable.
CMAKE_CPACK_COMMAND:INTERNAL=C:/ANDROID_SDK/cmake/3.22.1/bin/cpack.exe
//Path to ctest program executable.
CMAKE_CTEST_COMMAND:INTERNAL=C:/ANDROID_SDK/cmake/3.22.1/bin/ctest.exe
//ADVANCED property for variable: CMAKE_CXX_COMPILER
CMAKE_CXX_COMPILER-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_COMPILER
CMAKE_C_COMPILER-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS
CMAKE_C_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_DEBUG
CMAKE_C_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_MINSIZEREL
CMAKE_C_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_RELEASE
CMAKE_C_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_FLAGS_RELWITHDEBINFO
CMAKE_C_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_C_STANDARD_LIBRARIES
CMAKE_C_STANDARD_LIBRARIES-ADVANCED:INTERNAL=1
//Executable file format
CMAKE_EXECUTABLE_FORMAT:INTERNAL=Unknown
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS
CMAKE_EXE_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_DEBUG
CMAKE_EXE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_MINSIZEREL
CMAKE_EXE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELEASE
CMAKE_EXE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_EXE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//Name of external makefile project generator.
CMAKE_EXTRA_GENERATOR:INTERNAL=
//Name of generator.
CMAKE_GENERATOR:INTERNAL=NMake Makefiles
//Generator instance identifier.
CMAKE_GENERATOR_INSTANCE:INTERNAL=
//Name of generator platform.
CMAKE_GENERATOR_PLATFORM:INTERNAL=
//Name of generator toolset.
CMAKE_GENERATOR_TOOLSET:INTERNAL=
//Source directory with the top level CMakeLists.txt file for this
// project
CMAKE_HOME_DIRECTORY:INTERNAL=C:/MYOXYGEN-REPOS/PERSONAL/cicdtest/node_modules/react-native/sdks/hermes
//ADVANCED property for variable: CMAKE_LINKER
CMAKE_LINKER-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MAKE_PROGRAM
CMAKE_MAKE_PROGRAM-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS
CMAKE_MODULE_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_DEBUG
CMAKE_MODULE_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL
CMAKE_MODULE_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELEASE
CMAKE_MODULE_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_MODULE_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_MT
CMAKE_MT-ADVANCED:INTERNAL=1
//number of local generators
CMAKE_NUMBER_OF_MAKEFILES:INTERNAL=1
//Platform information initialized
CMAKE_PLATFORM_INFO_INITIALIZED:INTERNAL=1
//noop for ranlib
CMAKE_RANLIB:INTERNAL=:
//ADVANCED property for variable: CMAKE_RC_COMPILER
CMAKE_RC_COMPILER-ADVANCED:INTERNAL=1
CMAKE_RC_COMPILER_WORKS:INTERNAL=1
//ADVANCED property for variable: CMAKE_RC_FLAGS
CMAKE_RC_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_RC_FLAGS_DEBUG
CMAKE_RC_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_RC_FLAGS_MINSIZEREL
CMAKE_RC_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_RC_FLAGS_RELEASE
CMAKE_RC_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_RC_FLAGS_RELWITHDEBINFO
CMAKE_RC_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//Path to CMake installation.
CMAKE_ROOT:INTERNAL=C:/ANDROID_SDK/cmake/3.22.1/share/cmake-3.22
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS
CMAKE_SHARED_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_DEBUG
CMAKE_SHARED_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL
CMAKE_SHARED_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELEASE
CMAKE_SHARED_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_SHARED_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SKIP_INSTALL_RPATH
CMAKE_SKIP_INSTALL_RPATH-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_SKIP_RPATH
CMAKE_SKIP_RPATH-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS
CMAKE_STATIC_LINKER_FLAGS-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_DEBUG
CMAKE_STATIC_LINKER_FLAGS_DEBUG-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL
CMAKE_STATIC_LINKER_FLAGS_MINSIZEREL-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELEASE
CMAKE_STATIC_LINKER_FLAGS_RELEASE-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO
CMAKE_STATIC_LINKER_FLAGS_RELWITHDEBINFO-ADVANCED:INTERNAL=1
//ADVANCED property for variable: CMAKE_VERBOSE_MAKEFILE
CMAKE_VERBOSE_MAKEFILE-ADVANCED:INTERNAL=1

@mganandraj
Copy link
Contributor

Hi @MO-Lewis .. We regularly build react native from source on Windows. The key is to have a visual studio installation with Native/C++ build tools included (Even free community edition should work) and run gradle from the visual studio developer command prompt.

Many people faced problems because of file path length limitations on Windows which required some configuration and reducing the root directory paths.

Specifically on the usage of Nmake: NMake is slow and old, and we want to avoid using it. But unfortunately, ninja don't yet support long file paths on windows. Ref. ninja-build/ninja#1900.

@MO-Lewis
Copy link
Contributor Author

MO-Lewis commented Jun 9, 2023

Thanks for the reply @mganandraj! You can see the exact Visual Studio modules I have installed on my machine in the original post. If there's anything in there that looks like it's missing / conflicting, it'd be much appreciated if you could let me know!

I tried to use Visual Studio 2022 Developer Command Prompt v17.6.2 earlier on this week, and I believe I was getting a similar build error.

However...

I ran it again earlier to double-check the error produced, and it did appear to build with no issues on a boilerplate React project! I'm not sure what I was doing differently earlier this week, perhaps I messed up some environment variables around the same time, but it does appear to work with no issue now!

So this means that building from source on Windows is NOT impossible or broken, but there ARE additional, undocumented requirements.

I would definitely recommend that there should be some extra Windows-specific info in the build from source page, which states that the Windows user must:

  • Have MSVC vXXX VS 20XX C++ x64/86 Build Tools installed via Visual Studio.
  • Use the Visual Studio 20XX Developer Command Prompt to actually run the command that builds from source.

Once again, a huge thanks to you both for helping me with this issue over the last few days

@MO-Lewis
Copy link
Contributor Author

Just an update on this from what I found at the end of Friday.

Whilst I was able to get this working on a boilerplate React Native project, I was unable to get it working on our actual client project. React Native versions are the same, other package versions are the same, etc.

Our actual client project is giving me the "x86/cl.exe - broken" error. Really not sure what the error could be in this case.

I'll leave the issue open, as most people who have trouble building for Windows will likely end up seeing this issue (and can hopefully contribute a solution 😅)

@cortinico cortinico added Never gets stale Prevent those issues and PRs from getting stale and removed Newer Patch Available labels Jun 12, 2023
@joe-sam
Copy link

joe-sam commented Jun 20, 2023

To make all the pieces work together on Windows appear to be switching from ANSI to Unicode API calls - the *A to *W and switched to clang-cl.exe from cl.exe
It may be an exercise worth replicating.

Use *W versions of win32 file functions
#2289

facebook-github-bot pushed a commit that referenced this issue Jul 18, 2023
Summary:
Added code previously added in the following PR: #28659.

The above PR was accidentally scrapped due to the renaming of the master branch on the React Native repo. As advised in this comment: #37770 (comment), I'm opening a new PR with the same code to get this merged into master / main.

Currently, we need to run a local fork of React Native and manually apply these changes ourselves. This then causes additional issues, as it's currently _**impossible**_ to build React Native from source when running on a Windows machine, as evidenced in #37770 and the other linked issues nested inside of this issue.

**Original summary is as follows:**
With `NetworkModule.setCustomClientBuilder` we can customize our OkHttpClient to all requests made by react-native, it's very useful when you do `SSL Pinning` or change some OkHttpClient configuration at all. I've added a similar function to websocket, it allow us do some configurations on Websocket OkHttpClient.

## Changelog:
[Android] [Added] - Websocket Module setCustomClientBuilder

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: #37798

Test Plan:
**From the original PR:**

You can just set a custom `CustomClientBuilder` on `MainActivity` `onCreate`:

```
import okhttp3.OkHttpClient;
import java.util.concurrent.TimeUnit;
import com.facebook.react.modules.network.CustomClientBuilder;
import com.facebook.react.modules.websocket.WebsocketModule;

public class MainActivity extends ReactFragmentActivity {

    Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        RNBootSplash.init(R.drawable.launch_screen, MainActivity.this);

        WebsocketModule.setCustomClientBuilder(new CustomClientBuilder() {
            Override
            public void apply(OkHttpClient.Builder builder) {
              builder.connectTimeout(0, TimeUnit.MILLISECONDS);
            }
          });
    }

   ...
```

Reviewed By: cortinico

Differential Revision: D47468613

Pulled By: javache

fbshipit-source-id: ad97fb18ba5784d8abe157f5ccd29201b8b0fe84
juniorklawa pushed a commit to juniorklawa/react-native that referenced this issue Jul 20, 2023
Summary:
Added code previously added in the following PR: facebook#28659.

The above PR was accidentally scrapped due to the renaming of the master branch on the React Native repo. As advised in this comment: facebook#37770 (comment), I'm opening a new PR with the same code to get this merged into master / main.

Currently, we need to run a local fork of React Native and manually apply these changes ourselves. This then causes additional issues, as it's currently _**impossible**_ to build React Native from source when running on a Windows machine, as evidenced in facebook#37770 and the other linked issues nested inside of this issue.

**Original summary is as follows:**
With `NetworkModule.setCustomClientBuilder` we can customize our OkHttpClient to all requests made by react-native, it's very useful when you do `SSL Pinning` or change some OkHttpClient configuration at all. I've added a similar function to websocket, it allow us do some configurations on Websocket OkHttpClient.

## Changelog:
[Android] [Added] - Websocket Module setCustomClientBuilder

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: facebook#37798

Test Plan:
**From the original PR:**

You can just set a custom `CustomClientBuilder` on `MainActivity` `onCreate`:

```
import okhttp3.OkHttpClient;
import java.util.concurrent.TimeUnit;
import com.facebook.react.modules.network.CustomClientBuilder;
import com.facebook.react.modules.websocket.WebsocketModule;

public class MainActivity extends ReactFragmentActivity {

    Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        RNBootSplash.init(R.drawable.launch_screen, MainActivity.this);

        WebsocketModule.setCustomClientBuilder(new CustomClientBuilder() {
            Override
            public void apply(OkHttpClient.Builder builder) {
              builder.connectTimeout(0, TimeUnit.MILLISECONDS);
            }
          });
    }

   ...
```

Reviewed By: cortinico

Differential Revision: D47468613

Pulled By: javache

fbshipit-source-id: ad97fb18ba5784d8abe157f5ccd29201b8b0fe84
@yogesh6260
Copy link

Screenshot (39)

yarn run v1.22.19

$ npx react-native run-android --variant=experimentalPlayDebug

After running Rocket.Chat.ReactNative [(https://github.com/RocketChat/Rocket.Chat.ReactNative.git)] by cloning the git repo,
Got error - BUILD FAILED due to cmake command is not running, Can, anyone help me to resolve this issue?
I have spent lot of time to build this project but everytime I got this error, please, help me solve out if anyone can.

It is occuring at the time of EXECUTING.....

@sebasg0
Copy link

sebasg0 commented Aug 22, 2023

I'm getting same issue in macos M1 chip. CMake Error at /Library/Android/sdk/cmake/3.22.1/share/cmake-3.22/Modules/CMakeTestCCompiler.cmake:69 (message): The C compiler

@woshi82
Copy link

woshi82 commented Oct 25, 2023

@MO-Lewis
I have met this error too when i set newArcEnable: true.
My project is origin native APP intergrate with react-native .
I use Android studio to compile my project, and met this error
image

Then , I change to use Visual Studio 2022 Developer Command Prompt v17.6.2 to compile my project, and cmd showed more detail error.
image

It's look like my project or react-native in my project use x86 .conflict with my window11 system x64 ?

But I still finding how to solve the problem. If you know how to resolve the problem, can you let me know. Thank you .

DDRBoxman pushed a commit to discord/react-native that referenced this issue Feb 15, 2024
Summary:
Added code previously added in the following PR: facebook#28659.

The above PR was accidentally scrapped due to the renaming of the master branch on the React Native repo. As advised in this comment: facebook#37770 (comment), I'm opening a new PR with the same code to get this merged into master / main.

Currently, we need to run a local fork of React Native and manually apply these changes ourselves. This then causes additional issues, as it's currently _**impossible**_ to build React Native from source when running on a Windows machine, as evidenced in facebook#37770 and the other linked issues nested inside of this issue.

**Original summary is as follows:**
With `NetworkModule.setCustomClientBuilder` we can customize our OkHttpClient to all requests made by react-native, it's very useful when you do `SSL Pinning` or change some OkHttpClient configuration at all. I've added a similar function to websocket, it allow us do some configurations on Websocket OkHttpClient.

[Android] [Added] - Websocket Module setCustomClientBuilder

<!-- Help reviewers and the release process by writing your own changelog entry.

Pick one each for the category and type tags:

[ANDROID|GENERAL|IOS|INTERNAL] [BREAKING|ADDED|CHANGED|DEPRECATED|REMOVED|FIXED|SECURITY] - Message

For more details, see:
https://reactnative.dev/contributing/changelogs-in-pull-requests

Pull Request resolved: facebook#37798

Test Plan:
**From the original PR:**

You can just set a custom `CustomClientBuilder` on `MainActivity` `onCreate`:

```
import okhttp3.OkHttpClient;
import java.util.concurrent.TimeUnit;
import com.facebook.react.modules.network.CustomClientBuilder;
import com.facebook.react.modules.websocket.WebsocketModule;

public class MainActivity extends ReactFragmentActivity {

    Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        RNBootSplash.init(R.drawable.launch_screen, MainActivity.this);

        WebsocketModule.setCustomClientBuilder(new CustomClientBuilder() {
            Override
            public void apply(OkHttpClient.Builder builder) {
              builder.connectTimeout(0, TimeUnit.MILLISECONDS);
            }
          });
    }

   ...
```

Reviewed By: cortinico

Differential Revision: D47468613

Pulled By: javache

fbshipit-source-id: ad97fb18ba5784d8abe157f5ccd29201b8b0fe84
@cortinico cortinico added the Help Wanted :octocat: Issues ideal for external contributors. label Mar 7, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Help Wanted :octocat: Issues ideal for external contributors. Never gets stale Prevent those issues and PRs from getting stale Platform: Android Android applications. Platform: Windows Building on Windows.
Projects
None yet
Development

No branches or pull requests

7 participants