Qt Creator编译报错:找不到bits/c++config.h文件
Hey there, I’ve run into this exact error before when setting up Android builds with Qt—let’s walk through the most likely fixes step by step:
Verify NDK-Qt Creator Compatibility
First, double-check that your NDK version (I’m guessingandroid-ndk-rb16is a typo forr16) plays nice with your Qt Creator version. Older Qt releases (like Qt 5.9-5.11) work smoothly with NDK r10e-r16, but newer Qt versions (5.12+) prefer NDK r21e or later. If your Qt is too new for r16, consider either upgrading your NDK to a compatible version or downgrading Qt to match your existing NDK.Check Android Configuration in Qt Creator
Open Qt Creator, head toTools > Options > Devices > Androidand confirm:- The NDK path points exactly to
D:\android-ndk-r16(no typos, no missing subfolders) - SDK and JDK paths are properly set and valid
Click "Apply" and restart Qt Creator to ensure the settings take full effect.
- The NDK path points exactly to
Adjust STL Library Settings
The error stems from the gnu-libstdc++ 4.9 STL, which was deprecated starting in NDK r18. Let’s switch to the recommended LLVM libc++:- Open your project’s build settings (click the "Projects" tab on the left sidebar)
- Select your target Android kit
- Under "Build Environment" or "Android Build" settings, find the STL option
- Change it from
gnustl_shared/gnustl_statictoc++_shared(orc++_staticif you prefer a static build) - Run a full clean build: right-click your project >
Clean, thenRun qmake, thenBuild
Confirm NDK File Integrity
Sometimes NDK downloads get corrupted mid-transfer. Navigate toD:\android-ndk-r16\sources\cxx-stl\gnu-libstdc++\4.9\include\bits—ifc++config.his missing here, your NDK install is incomplete. Delete the entire NDK folder and re-download it from the official archive (make sure to pick the correct Windows version).Wipe Build Cache
Corrupted build artifacts can cause weird include errors. Delete your project’sbuild-*folder (located in the same directory as your.profile), then recompile from scratch.
If none of these work, drop a note with your exact Qt Creator version—I can help narrow it down further!
内容的提问来源于stack exchange,提问作者Thomas

