HarmonyOS鸿蒙Next Native开发中提示clang: error: unable to execute command: program not executable

HarmonyOS鸿蒙Next Native开发中提示clang: error: unable to execute command: program not executable Hi guys,

我遇到这样的问题:编译 native cmake 工程时,clang 出错提示如下:

clang: error: unable to execute command: program not executable
clang: error: assembler command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.

我的 cmd 脚本如下:

@ECHO OFF
@SETLOCAL

:: set your HarmonyOS Huawei SDK version
::@SET Harmony_VER=3.0.1.93
@SET Harmony_VER=3.0.0.80

:: set your HarmonyOS Huawei SDK root path
@SET Harmony_SDK=D:/Program/HarmonyOS

::

:: now can get HarmonyOS native toolchain file path
@SET Harmony_NATIVE_TOOLCHAIN="%Harmony_SDK%/native/%Harmony_VER%/build/cmake/ohos.toolchain.cmake"

:: set other exec environment path
@SET PATH="%Harmony_SDK%/native/%Harmony_VER%/llvm/bin";"%Harmony_SDK%/native/%Harmony_VER%/build-tools/cmake/bin";%PATH%

:: HarmonyOS ARMv7
mkdir build-harmony-armv7
pushd build-harmony-armv7
cmake.exe -G Ninja -DCMAKE_TOOLCHAIN_FILE=%Harmony_NATIVE_TOOLCHAIN% -DCMAKE_MAKE_PROGRAM="%Harmony_SDK%/native/%Harmony_VER%/build-tools/cmake/bin/ninja.exe" -DOHOS_ARCH="armeabi-v7a" -DOHOS_ARM_NEON=ON ..
cmake.exe --build . --parallel %NUMBER_OF_PROCESSORS% && cmake.exe --build . --target install
popd

@pause

:: HarmonyOS aarch64
mkdir build-harmony-aarch64
pushd build-harmony-aarch64
cmake.exe -G Ninja -DCMAKE_TOOLCHAIN_FILE=%Harmony_NATIVE_TOOLCHAIN% -DCMAKE_MAKE_PROGRAM="%Harmony_SDK%/native/%Harmony_VER%/build-tools/cmake/bin/ninja.exe" -DOHOS_ARCH="arm64-v8a" ..
cmake.exe --build . --parallel %NUMBER_OF_PROCESSORS% && cmake.exe --build . --target install
popd

@ENDLOCAL

经过验证,其中路径 %Harmony_NATIVE_TOOLCHAIN% %Harmony_VER% 等均是对的,环境也在此脚本中设置了 PATH,也检查了设置是正确的路径,那么还有哪里是我没注意到的?

谢谢浏览和解决我的问题。


更多关于HarmonyOS鸿蒙Next Native开发中提示clang: error: unable to execute command: program not executable的实战教程也可以访问 https://www.itying.com/category-93-b0.html

6 回复

请问楼主如何解决的啊?

更多关于HarmonyOS鸿蒙Next Native开发中提示clang: error: unable to execute command: program not executable的实战系列教程也可以访问 https://www.itying.com/category-93-b0.html


我自己解决了,修正 Harmony SDK 的不同版本的这个类似 Android NDK 的 -fno-integrated-as 问题时带来的相关问题。

希望HarmonyOS能继续优化系统稳定性,减少崩溃和重启的情况。

亲爱滴开发者 ,这个问题已经在处理中啦,稍后答复你哟 ,么么哒

在HarmonyOS鸿蒙Next Native开发中,出现"clang: error: unable to execute command: program not executable"错误,通常是由于以下原因之一:

  1. 编译器路径配置错误:检查开发环境中的编译器路径是否正确配置,确保clang可执行文件路径正确。

  2. 权限问题:确保clang可执行文件具有执行权限。可以通过chmod +x命令赋予执行权限。

  3. 环境变量问题:检查环境变量是否包含clang的路径,确保在命令行中可以直接调用clang。

  4. 文件损坏或缺失:确认clang可执行文件是否完整且未损坏,必要时重新安装或更新编译器。

  5. 系统架构不匹配:确保clang可执行文件与当前系统的架构匹配,例如在ARM架构上使用ARM版本的clang。

  6. 依赖库缺失:检查clang依赖的库是否完整,确保所有必要的库都已安装。

  7. 开发工具版本不兼容:确认使用的开发工具版本与HarmonyOS鸿蒙Next Native开发环境兼容。

  8. 路径包含特殊字符:确保clang可执行文件路径不包含特殊字符或空格,可能导致执行失败。

  9. 系统资源不足:检查系统资源是否充足,如内存和磁盘空间,确保有足够资源执行clang。

  10. 病毒或恶意软件干扰:扫描系统,确保没有病毒或恶意软件干扰clang的执行。

以上是可能导致"clang: error: unable to execute command: program not executable"错误的原因,逐一排查可解决问题。

在HarmonyOS鸿蒙Next Native开发中,出现“clang: error: unable to execute command: program not executable”错误,通常是由于以下原因之一:

  1. 编译器路径错误:确保clang编译器路径正确配置,检查环境变量PATH是否包含clang的安装路径。

  2. 权限问题:检查clang可执行文件是否具有执行权限,使用chmod +x /path/to/clang赋予执行权限。

  3. 文件损坏:clang可执行文件可能损坏,尝试重新安装或更新编译器。

  4. 系统架构不匹配:确保clang版本与系统架构(如x86、ARM)匹配。

  5. 依赖缺失:检查clang依赖的库是否完整,使用ldd /path/to/clang查看依赖关系。

解决这些问题后,重新编译项目即可。

回到顶部