HarmonyOS 鸿蒙Next:libuv在windows平台交叉编译成鸿蒙版本报错

发布于 1周前 作者 itying888 来自 鸿蒙OS

HarmonyOS 鸿蒙Next:libuv在windows平台交叉编译成鸿蒙版本报错

报错内容:

PS F:\ty\project\android\develop\openssl> ohrs build --release

   Compiling proc-macro2 v1.0.86

   Compiling unicode-ident v1.0.12

   Compiling memchr v2.7.4

   Compiling regex-syntax v0.8.4

   Compiling cc v1.0.104

   Compiling unicode-segmentation v1.11.0

   Compiling once_cell v1.19.0

   Compiling napi-build-ohos v1.0.0-beta.2

   Compiling bitflags v2.6.0

   Compiling napi-sys-ohos v1.0.0-beta.2

   Compiling cfg-if v1.0.0

   Compiling convert_case v0.6.0                                                                                                                                     

   Compiling aho-corasick v1.1.3                                                                                                                                    

   Compiling quote v1.0.36                                                                                                                                          

   Compiling cmake v0.1.50                                                                                                                                          

   Compiling syn v2.0.68                                                                                                                                            

   Compiling openssl v0.1.0 (F:\ty\project\android\develop\openssl)                                                                                                 

warning: variable does not need to be mutable                                                                                                                       

  --> src/build.rs:75:21

   |

75 |                 let mut android_ndk_home = std::env::var(“ANDROID_NDK_HOME”);

   |                     ----^^^^^^^^^^^^^^^^

   |                     |

   |                     help: remove this mut

   |

   = note: #[warn(unused_mut)] on by default

warning: unused variable: use_local

   --> src/build.rs:141:9

    |

141 |     let use_local = false;

    |         ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: _use_local

    |

    = note: #[warn(unused_variables)] on by default

warning: openssl (build script) generated 2 warnings                                                                                                              

   Compiling regex-automata v0.4.7                                                                                                                                  

   Compiling regex v1.10.5                                                                                                                                          

   Compiling napi-derive-backend-ohos v1.0.0-beta.2                                                                                                                 

error: failed to run custom build command for openssl v0.1.0 (F:\ty\project\android\develop\openssl)                                                              

Caused by:

  process didn’t exit successfully: F:\ty\project\android\develop\openssl\target\release\build\openssl-3dbf1b6836962374\build-script-build (exit code: 101)        

  — stdout

  cargo:rerun-if-env-changed=DEBUG_GENERATED_CODE

  cargo:rerun-if-env-changed=TYPE_DEF_TMP_PATH

  cargo:rerun-if-env-changed=NAPI_BUILD_TARGET_NAME

  cargo:rerun-if-env-changed=CARGO_CFG_NAPI_RS_CLI_VERSION

  cargo:rustc-env=NAPI_BUILD_TARGET_NAME=openssl

  cargo:rustc-link-lib=dylib=ace_napi.z

  CMAKE_GENERATOR_aarch64-unknown-linux-ohos = None

  CMAKE_GENERATOR_aarch64_unknown_linux_ohos = None

  TARGET_CMAKE_GENERATOR = None

  CMAKE_GENERATOR = None

  CMAKE_PREFIX_PATH_aarch64-unknown-linux-ohos = None

  CMAKE_PREFIX_PATH_aarch64_unknown_linux_ohos = None

  TARGET_CMAKE_PREFIX_PATH = None

  CMAKE_PREFIX_PATH = None

  CMAKE_aarch64-unknown-linux-ohos = None

  CMAKE_aarch64_unknown_linux_ohos = None

  TARGET_CMAKE = None

  CMAKE = None

  running: “cmake” “F:\ty\project\android\develop\openssl\deps/uv” “-DOHOS_ARCH=arm64-v8a” “-DCMAKE_TOOLCHAIN_FILE=F:/application/DevEcoStudio/sdk/HarmonyOS-NE

XT-DB1/openharmony/native/build/cmake/ohos.toolchain.cmake” “-DCMAKE_INSTALL_PREFIX=F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\r

elease\build\openssl-08f9bfc2bf80788a\out” “-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=aarch64-unknown-linux-ohos” “-DCMAKE_CXX_FLAGS= -f

function-sections -fdata-sections -fPIC --target=aarch64-unknown-linux-ohos” “-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=aarch64-unknown-linux-ohos” “-DCMAKE_BUILD_TYPE=Release”

  – Building for: Visual Studio 17 2022

  – The C compiler identification is MSVC 19.40.33811.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.40.33807/bin/Hostx64/x64/cl.exe

  – Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - broken

  – Configuring incomplete, errors occurred!

  — stderr

  System is unknown to cmake, create:

  Platform/OHOS to use this system, please post your config file on discourse.cmake.org so it can be added to cmake

  System is unknown to cmake, create:

  Platform/OHOS to use this system, please post your config file on discourse.cmake.org so it can be added to cmake

  System is unknown to cmake, create:

  Platform/OHOS to use this system, please post your config file on discourse.cmake.org so it can be added to cmake

  CMake Error at F:/application/CMake/share/cmake-3.29/Modules/CMakeTestCCompiler.cmake:67 (message):

    The C compiler

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

    is not able to compile a simple test program.

    It fails with the following output:

      Change Dir: ‘F:/ty/project/android/develop/openssl/target/aarch64-unknown-linux-ohos/release/build/openssl-08f9bfc2bf80788a/out/build/CMakeFiles/CMakeScratch/TryCompile-svgx8u’

      Run Build Command(s): “C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/amd64/MSBuild.exe” cmTC_46f81.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:n

      适用于 .NET Framework MSBuild 版本 17.10.4+10fbfbf2e

      生成启动时间为 2024/7/10 12:46:19。

      节点 1 上的项目“F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-svgx8u\cmTC_46f81.vcxproj”(默认目标)。

      PrepareForBuild:

        正在创建目录“cmTC_46f81.dir\Debug\”。

        已启用结构化输出。编译器诊断的格式设置将反映错误层次结构。有关详细信息,请参阅 https://aka.ms/cpp/structured-output

        正在创建目录“F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-svgx8u\Debug\”。

        正在创建目录“cmTC_46f81.dir\Debug\cmTC_46f81.tlog\”。

      InitializeBuildStatus:

        正在创建“cmTC_46f81.dir\Debug\cmTC_46f81.tlog\unsuccessfulbuild”,因为已指定“AlwaysCreate”。

        正在对“cmTC_46f81.dir\Debug\cmTC_46f81.tlog\unsuccessfulbuild”执行 Touch 任务。

      ClCompile:

        C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\bin\HostX64\x64\CL.exe /c /W1 /WX- /diagnostics:column /O2 /D _MBCS 

/D MUSL /D “CMAKE_INTDIR=“Debug”” /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_46f81.dir\Debug\" /Fd"cmTC_46f81.dir\Debug\vc143.pdb" 

/external:W1 /Gd /TC /errorReport:queue  -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,–noexe

cstack -Wformat -Werror=format-security -ffunction-sections -fdata-sections -fPIC --target=aarch64-unknown-linux-ohos -O0 -g -fno-limit-debug-info “F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-svgx8u\testCCompiler.c”   

        用于 x64 的 Microsoft ® C/C++ 优化编译器 19.40.33811 版

        版权所有© Microsoft Corporation。保留所有权利。

        cl /c /W1 /WX- /diagnostics:column /O2 /D _MBCS /D MUSL /D “CMAKE_INTDIR=“Debug”” /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC

_46f81.dir\Debug\" /Fd"cmTC_46f81.dir\Debug\vc143.pdb" /external:W1 /Gd /TC /errorReport:queue  -fdata-sections -ffunction-sections -funwind-tables -fstack-protecto

r-strong -no-canonical-prefixes -fno-addrsig -Wa,–noexecstack -Wformat -Werror=format-security -ffunction-sections -fdata-sections -fPIC --target=aarch64-unknown-li

nux-ohos -O0 -g -fno-limit-debug-info “F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-svgx8u\testCCompiler.c”

      cl : 命令行  error D8021: 无效的数值参数“/Wa,–noexecstack” [F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-svgx8u\cmTC_46f81.vcxproj]

      已完成生成项目“F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-svgx8u\cmTC_46f81.vcxproj”(默认目标)的操作 - 失败。

      生成失败。

      “F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-svgx8u\cmTC_46f81.vcxproj”(默认目标) (1) ->

      (ClCompile 目标) ->

        cl : 命令行  error D8021: 无效的数值参数“/Wa,–noexecstack” [F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-svgx8u\cmTC_46f81.vcxproj]

          0 个警告

          1 个错误

      已用时间 00:00:00.43

    CMake will not be able to correctly generate this project.

  Call Stack (most recent call first):

    CMakeLists.txt:10 (project)

  thread ‘main’ panicked at C:\Users\93416.cargo\registry\src\index.crates.io-6f17d22bba15001f\cmake-0.1.50\src\lib.rs:1098:5:

  command did not execute successfully, got: exit code: 1

  build script failed, must exit now

  note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

warning: build failed, waiting for other jobs to finish…

PS F:\ty\project\android\develop\openssl> ohrs build --release                                                                                                      

warning: variable does not need to be mutable

  --> src/build.rs:75:21

   |

75 |                 let mut android_ndk_home = std::env::var(“ANDROID_NDK_HOME”);

   |                     ----^^^^^^^^^^^^^^^^

   |                     |

   |                     help: remove this mut

   |

   = note: #[warn(unused_mut)] on by default

warning: unused variable: use_local

   --> src/build.rs:141:9

    |

141 |     let use_local = false;

    |         ^^^^^^^^^ help: if this is intentional, prefix it with an underscore: _use_local

    |

    = note: #[warn(unused_variables)] on by default

warning: openssl (build script) generated 2 warnings

   Compiling openssl v0.1.0 (F:\ty\project\android\develop\openssl)

   Compiling ctor v0.2.8

   Compiling napi-derive-ohos v1.0.0-beta.2

   Compiling napi-ohos v1.0.0-beta.2                                                                                                                                

error: failed to run custom build command for openssl v0.1.0 (F:\ty\project\android\develop\openssl)                                                              

Caused by:

  process didn’t exit successfully: F:\ty\project\android\develop\openssl\target\release\build\openssl-3dbf1b6836962374\build-script-build (exit code: 101)        

  — stdout

  cargo:rerun-if-env-changed=DEBUG_GENERATED_CODE

  cargo:rerun-if-env-changed=TYPE_DEF_TMP_PATH

  cargo:rerun-if-env-changed=NAPI_BUILD_TARGET_NAME

  cargo:rerun-if-env-changed=CARGO_CFG_NAPI_RS_CLI_VERSION

  cargo:rustc-env=NAPI_BUILD_TARGET_NAME=openssl

  cargo:rustc-link-lib=dylib=ace_napi.z

  CMAKE_GENERATOR_aarch64-unknown-linux-ohos = None

  CMAKE_GENERATOR_aarch64_unknown_linux_ohos = None

  TARGET_CMAKE_GENERATOR = None

  CMAKE_GENERATOR = None

  CMAKE_PREFIX_PATH_aarch64-unknown-linux-ohos = None

  CMAKE_PREFIX_PATH_aarch64_unknown_linux_ohos = None

  TARGET_CMAKE_PREFIX_PATH = None

  CMAKE_PREFIX_PATH = None

  CMAKE_aarch64-unknown-linux-ohos = None

  CMAKE_aarch64_unknown_linux_ohos = None

  TARGET_CMAKE = None

  CMAKE = None

  running: “cmake” “F:\ty\project\android\develop\openssl\deps/uv” “-DOHOS_ARCH=arm64-v8a” “-DCMAKE_TOOLCHAIN_FILE=F:/application/DevEcoStudio/sdk/HarmonyOS-NE

XT-DB1/openharmony/native/build/cmake/ohos.toolchain.cmake” “-DCMAKE_INSTALL_PREFIX=F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\r

elease\build\openssl-08f9bfc2bf80788a\out” “-DCMAKE_C_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=aarch64-unknown-linux-ohos” “-DCMAKE_CXX_FLAGS= -f

function-sections -fdata-sections -fPIC --target=aarch64-unknown-linux-ohos” “-DCMAKE_ASM_FLAGS= -ffunction-sections -fdata-sections -fPIC --target=aarch64-unknown-linux-ohos” “-DCMAKE_BUILD_TYPE=Release”

  – The C compiler identification is MSVC 19.40.33811.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.40.33807/bin/Hostx64/x64/cl.exe

  – Check for working C compiler: C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/VC/Tools/MSVC/14.40.33807/bin/Hostx64/x64/cl.exe - broken

  – Configuring incomplete, errors occurred!

  — stderr

  System is unknown to cmake, create:

  Platform/OHOS to use this system, please post your config file on discourse.cmake.org so it can be added to cmake

  Your CMakeCache.txt file was copied to CopyOfCMakeCache.txt. Please post that file on discourse.cmake.org.

  System is unknown to cmake, create:

  Platform/OHOS to use this system, please post your config file on discourse.cmake.org so it can be added to cmake

  System is unknown to cmake, create:

  Platform/OHOS to use this system, please post your config file on discourse.cmake.org so it can be added to cmake

  CMake Error at F:/application/CMake/share/cmake-3.29/Modules/CMakeTestCCompiler.cmake:67 (message):

    The C compiler

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

    is not able to compile a simple test program.

    It fails with the following output:

      Change Dir: ‘F:/ty/project/android/develop/openssl/target/aarch64-unknown-linux-ohos/release/build/openssl-08f9bfc2bf80788a/out/build/CMakeFiles/CMakeScratch/TryCompile-596erb’

      Run Build Command(s): “C:/Program Files (x86)/Microsoft Visual Studio/2022/BuildTools/MSBuild/Current/Bin/amd64/MSBuild.exe” cmTC_66679.vcxproj /p:Configuration=Debug /p:Platform=x64 /p:VisualStudioVersion=17.0 /v:n

      适用于 .NET Framework MSBuild 版本 17.10.4+10fbfbf2e

      生成启动时间为 2024/7/10 12:50:18。

      节点 1 上的项目“F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-596erb\cmTC_66679.vcxproj”(默认目标)。

      PrepareForBuild:

        正在创建目录“cmTC_66679.dir\Debug\”。

        已启用结构化输出。编译器诊断的格式设置将反映错误层次结构。有关详细信息,请参阅 https://aka.ms/cpp/structured-output

        正在创建目录“F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-596erb\Debug\”。

        正在创建目录“cmTC_66679.dir\Debug\cmTC_66679.tlog\”。

      InitializeBuildStatus:

        正在创建“cmTC_66679.dir\Debug\cmTC_66679.tlog\unsuccessfulbuild”,因为已指定“AlwaysCreate”。

        正在对“cmTC_66679.dir\Debug\cmTC_66679.tlog\unsuccessfulbuild”执行 Touch 任务。

      ClCompile:

        C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\bin\HostX64\x64\CL.exe /c /W1 /WX- /diagnostics:column /O2 /D _MBCS 

/D MUSL /D “CMAKE_INTDIR=“Debug”” /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC_66679.dir\Debug\" /Fd"cmTC_66679.dir\Debug\vc143.pdb" 

/external:W1 /Gd /TC /errorReport:queue  -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,–noexe

cstack -Wformat -Werror=format-security -ffunction-sections -fdata-sections -fPIC --target=aarch64-unknown-linux-ohos -O0 -g -fno-limit-debug-info “F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-596erb\testCCompiler.c”   

        用于 x64 的 Microsoft ® C/C++ 优化编译器 19.40.33811 版

        版权所有© Microsoft Corporation。保留所有权利。

        cl /c /W1 /WX- /diagnostics:column /O2 /D _MBCS /D MUSL /D “CMAKE_INTDIR=“Debug”” /Gm- /MD /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /Fo"cmTC

_66679.dir\Debug\" /Fd"cmTC_66679.dir\Debug\vc143.pdb" /external:W1 /Gd /TC /errorReport:queue  -fdata-sections -ffunction-sections -funwind-tables -fstack-protecto

r-strong -no-canonical-prefixes -fno-addrsig -Wa,–noexecstack -Wformat -Werror=format-security -ffunction-sections -fdata-sections -fPIC --target=aarch64-unknown-li

nux-ohos -O0 -g -fno-limit-debug-info “F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-596erb\testCCompiler.c”

      cl : 命令行  error D8021: 无效的数值参数“/Wa,–noexecstack” [F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-596erb\cmTC_66679.vcxproj]

      已完成生成项目“F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-596erb\cmTC_66679.vcxproj”(默认目标)的操作 - 失败。

      生成失败。

      “F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-596erb\cmTC_66679.vcxproj”(默认目标) (1) ->

      (ClCompile 目标) ->

        cl : 命令行  error D8021: 无效的数值参数“/Wa,–noexecstack” [F:\ty\project\android\develop\openssl\target\aarch64-unknown-linux-ohos\release\build\openssl-08f9bfc2bf80788a\out\build\CMakeFiles\CMakeScratch\TryCompile-596erb\cmTC_66679.vcxproj]

          0 个警告

          1 个错误

      已用时间 00:00:00.30

    CMake will not be able to correctly generate this project.

  Call Stack (most recent call first):

    CMakeLists.txt:10 (project)

  thread ‘main’ panicked at C:\Users\93416.cargo\registry\src\index.crates.io-6f17d22bba15001f\cmake-0.1.50\src\lib.rs:1098:5:

  command did not execute successfully, got: exit code: 1

  build script failed, must exit now

  note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

2 回复

在HarmonyOS(鸿蒙)上进行libuv的交叉编译到Windows平台通常不是直接支持的场景,因为鸿蒙主要是为华为设备设计的操作系统,其编译链和API与标准Windows平台有较大差异。报错可能源于多种原因,如API不兼容、依赖库缺失或交叉编译配置错误。

建议检查以下几点:

  1. 确保使用了正确的交叉编译工具链和配置文件。
  2. 验证所有依赖库是否都已正确适配鸿蒙。
  3. 查阅鸿蒙官方文档或社区,看是否有类似问题的解决方案。

如果问题依旧没法解决请加我微信,我的微信是itying888。

回到顶部