You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Mac环境下QT Creator编译Android应用提示G++文件缺失求助

Fixing Qt Creator Android Compilation Errors on Mac (Missing G++ Toolchain)

Hey there, let's break down your problem and fix it step by step. First, the root cause of those "No such file or directory" errors is simple: the newer NDK versions (r18+) have removed the GCC 4.9 toolchain (the arm-linux-androideabi-g++ and x86-4.9 tools you're missing). Google deprecated GCC in favor of Clang as the official Android compiler, so your NDK no longer includes those old GCC binaries.

You don't need to install a system-wide G++ (that's for native Mac development, not Android) or mess with complex toolchain scripts. Instead, let's configure Qt Creator to use Clang — which is already included in your NDK and is the modern, supported approach.

Step-by-Step Solutions

1. Configure Qt Creator to Use Clang for Android Compilation

This is the recommended fix, as Clang is now the standard compiler for Android NDK.

  • Open Qt Creator, then go to Qt Creator > Settings (or Preferences on older versions) from the top menu.
  • In the left sidebar, select Devices > Android:
    • Verify your Android SDK Location and Android NDK Location are correctly set to your paths:
      • SDK: /Users/drob/Library/Android/sdk
      • NDK: /Users/drob/Library/Android/sdk/ndk-bundle
  • Next, switch to the Kits tab in the left sidebar:
    • Find your Android build kit (e.g., Android 13 for armeabi-v7a (Qt 6.x.x) — the exact name depends on your Qt version and Android API level).
    • Click on the kit to edit it, then go to the Compiler tab:
      • For C compiler, select the Android Clang (arm-linux-androideabi) option matching your NDK version.
      • For C++ compiler, select the corresponding Android Clang++ (arm-linux-androideabi) option.
  • Click Apply to save the changes.
  • Close and re-open your Qt project, select the updated Android kit, and try compiling again.

If you absolutely need to use GCC (e.g., for legacy code compatibility), you'll need to install an older NDK version that still includes the GCC 4.9 toolchain (the last supported version is NDK r17c):

  • Download NDK r17c via Android Studio's SDK Manager: go to Tools > SDK Manager > SDK Tools, check "Show Package Details", and select NDK r17c from the dropdown.
  • In Qt Creator's Devices > Android settings, change the Android NDK Location to point to the older NDK folder (instead of ndk-bundle).
  • Update your build kit to use the GCC toolchains from this older NDK.

Clarifying Your Questions

  • What is G++? G++ is the GNU C++ compiler, used for native Linux/Mac development. For Android, you don't need the system-wide Mac G++ — Android uses its own toolchains from the NDK, which are now Clang-based.
  • Can Qt use Clang instead of G++? Absolutely! This is now the default and supported way to compile Android apps with Qt. The errors you're seeing are just Qt trying to use the deprecated GCC toolchain instead of the available Clang one.

内容的提问来源于stack exchange,提问作者Sergey Drobyshevskiy

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 09:07:30