Failed :entry:default@BuildNativeWithCmake... HarmonyOS 鸿蒙Next

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

Failed :entry:default@BuildNativeWithCmake… HarmonyOS 鸿蒙Next

> hvigor ERROR: Failed :entry:default@BuildNativeWithCmake… 

> hvigor ERROR: Exceptions happened while executing: Not searching for unused variables given on the command line.

– The C compiler identification is Clang 15.0.4

– The CXX compiler identification is unknown

– Detecting C compiler ABI info

– Detecting C compiler ABI info - done

– Check for working C compiler: /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang - skipped

– Detecting C compile features

– Detecting C compile features - done

– Detecting CXX compiler ABI info

– Detecting CXX compiler ABI info - failed

– Check for working CXX compiler: /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang++

– Check for working CXX compiler: /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang++ - broken

CMake Error at /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/build-tools/cmake/share/cmake-3.28/Modules/CMakeTestCXXCompiler.cmake:60 (message):

  The C++ compiler

    “/Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang++”

  is not able to compile a simple test program.

  It fails with the following output:

    Change Dir: ‘/Users/vincent/BambooCloud/sag/testSO/entry/.cxx/default/default/debug/arm64-v8a/CMakeFiles/CMakeScratch/TryCompile-cEgMiK’

    

    Run Build Command(s): /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/build-tools/cmake/bin/ninja -v cmTC_8439e

    [1/2] /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang++  -I/Applications/DevEco-Studio.app/Contents/sdk/default/hms/native/sysroot/usr/include -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,–noexecstack -Wformat -Werror=format-security   -D__MUSL__ -o CMakeFiles/cmTC_8439e.dir/testCXXCompiler.cxx.o -c /Users/vincent/BambooCloud/sag/testSO/entry/.cxx/default/default/debug/arm64-v8a/CMakeFiles/CMakeScratch/TryCompile-cEgMiK/testCXXCompiler.cxx

    [2/2] : && /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang++ -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,–noexecstack -Wformat -Werror=format-security   -D__MUSL__ --rtlib=compiler-rt -fuse-ld=lld -Wl,–build-id=sha1 -Wl,–warn-shared-textrel -Wl,–fatal-warnings -lunwind -Wl,–no-undefined -Qunused-arguments -Wl,-z,noexecstack -Wl,–gc-sections CMakeFiles/cmTC_8439e.dir/testCXXCompiler.cxx.o -o cmTC_8439e  -lm && :

    FAILED: cmTC_8439e 

    : && /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang++ -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,–noexecstack -Wformat -Werror=format-security   -D__MUSL__ --rtlib=compiler-rt -fuse-ld=lld -Wl,–build-id=sha1 -Wl,–warn-shared-textrel -Wl,–fatal-warnings -lunwind -Wl,–no-undefined -Qunused-arguments -Wl,-z,noexecstack -Wl,–gc-sections CMakeFiles/cmTC_8439e.dir/testCXXCompiler.cxx.o -o cmTC_8439e  -lm && :

    ld64.lld: error: unknown argument ‘–build-id=sha1’

    ld64.lld: error: unknown argument ‘–warn-shared-textrel’

    ld64.lld: error: unknown argument ‘–fatal-warnings’

    ld64.lld: error: unknown argument ‘–no-undefined’

    ld64.lld: error: unknown argument ‘-z’

    ld64.lld: error: unknown argument ‘–gc-sections’

    clang++: 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:3 (project)

– Configuring incomplete, errors occurred!

> hvigor ERROR: BUILD FAILED in 2 s 136 ms 

4 回复

这个要排查自己的编译脚本和报错参数

 ld64.lld: error: unknown argument '--build-id=sha1'

    ld64.lld: error: unknown argument '--warn-shared-textrel'

    ld64.lld: error: unknown argument '--fatal-warnings'

    ld64.lld: error: unknown argument '--no-undefined'

    ld64.lld: error: unknown argument '-z'

    ld64.lld: error: unknown argument '--gc-sections'

我把这些删除了后报这个错误 hvigor ERROR: Failed :entry:default@BuildNativeWithCmake… > hvigor ERROR: Exceptions happened while executing: Not searching for unused variables given on the command line. – The C compiler identification is Clang 15.0.4 – The CXX compiler identification is unknown – Detecting C compiler ABI info – Detecting C compiler ABI info - done – Check for working C compiler: /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang - skipped – Detecting C compile features – Detecting C compile features - done – Detecting CXX compiler ABI info – Detecting CXX compiler ABI info - failed – Check for working CXX compiler: /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang++ – Check for working CXX compiler: /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang++ - broken CMake Error at /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/build-tools/cmake/share/cmake-3.28/Modules/CMakeTestCXXCompiler.cmake:60 (message): The C++ compiler

"/Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang++"

is not able to compile a simple test program.

It fails with the following output:

Change Dir: '/Users/vincent/BambooCloud/sag/testSO/entry/.cxx/default/default/debug/arm64-v8a/CMakeFiles/CMakeScratch/TryCompile-irmBXU'

Run Build Command(s): /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/build-tools/cmake/bin/ninja -v cmTC_50fca
[1/2] /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang++  -I/Applications/DevEco-Studio.app/Contents/sdk/default/hms/native/sysroot/usr/include -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security   -D__MUSL__ -o CMakeFiles/cmTC_50fca.dir/testCXXCompiler.cxx.o -c /Users/vincent/BambooCloud/sag/testSO/entry/.cxx/default/default/debug/arm64-v8a/CMakeFiles/CMakeScratch/TryCompile-irmBXU/testCXXCompiler.cxx
[2/2] : && /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang++ -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security   -D__MUSL__ --rtlib=compiler-rt -fuse-ld=lld -Qunused-arguments CMakeFiles/cmTC_50fca.dir/testCXXCompiler.cxx.o -o cmTC_50fca   && :
FAILED: cmTC_50fca 
: && /Applications/DevEco-Studio.app/Contents/sdk/default/openharmony/native/llvm/bin/clang++ -fdata-sections -ffunction-sections -funwind-tables -fstack-protector-strong -no-canonical-prefixes -fno-addrsig -Wa,--noexecstack -Wformat -Werror=format-security   -D__MUSL__ --rtlib=compiler-rt -fuse-ld=lld -Qunused-arguments CMakeFiles/cmTC_50fca.dir/testCXXCompiler.cxx.o -o cmTC_50fca   && :
ld64.lld: error: library not found for -lc++
ld64.lld: error: library not found for -lSystem
clang++: 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):

编译一直报这个错误,哪个好心人帮忙解答一下

针对您提到的“Failed :entry:default@BuildNativeWithCmake… HarmonyOS 鸿蒙Next”编译错误,这通常与CMake配置或构建环境设置有关。以下是一些可能的解决方向:

  1. 检查CMakeLists.txt:确保CMake配置文件中的路径、库依赖、编译器设置等正确无误。特别是针对HarmonyOS的特殊配置,需要确认是否遵循了鸿蒙系统的构建规范。

  2. 环境变量:检查系统的环境变量设置,确保NDK、SDK等路径正确配置,并且版本与HarmonyOS要求相匹配。

  3. 编译命令:确认使用的编译命令及参数是否适用于HarmonyOS。有时特定的编译选项或参数可能不被支持。

  4. 依赖库:检查项目依赖的第三方库是否兼容HarmonyOS,或者是否需要特定的鸿蒙版本。

  5. 清理并重建:尝试清理项目(如使用ninja clean或删除构建目录),然后重新构建,以解决可能的构建缓存问题。

如果问题依旧没法解决请联系官网客服,官网地址是:https://www.itying.com/category-93-b0.html 。希望这些信息能对您有所帮助!

回到顶部