Troubleshooting
Fix common SPECS NDK build problems on macOS and Windows hosts, from toolchain selection to libc++ headers.
Fixes for common problems when you build with the SPECS NDK's CMake toolchain on a macOS or Windows host. In SPECS NDK v1.3.0, CMake with SpecsNDK-Toolchain-Clang.cmake is the supported way to build for SPECS; see Build your first Native Lens.
SPECS NDK build problems and fixes
| Symptom | Host | Likely cause | Fix |
|---|---|---|---|
cannot find -lgcc_s / missing libgcc / unresolved CRT symbols (Windows Clang) | Windows | --gcc-install-dir not set, for example, when invoking llvm-mingw clang.exe directly without the SpecsNDK toolchain file | Use SpecsNDK-Toolchain-Clang.cmake (it adds --gcc-install-dir=<sysroot>/usr/lib/aarch64-snap-linux/13.4.0 automatically), or pass that flag yourself |
_LIBCPP_VERSION mismatch / unexpected libc++ headers | Windows | llvm-mingw's bundled libc++ headers won by default | Use SpecsNDK-Toolchain-Clang.cmake (it injects -nostdinc++ -cxx-isystem <target-sysroot>/usr/include/c++/v1 to pin the target libc++ 1.0 headers) |
| CMake picks the host's clang instead of the SDK's | macOS / Windows | -DCMAKE_TOOLCHAIN_FILE not passed, or passed after first configure | Pass on first configure, or wipe build/ and re-configure |
| Re-running CMake after moving the SDK fails | macOS / Windows | Paths cached in build/ | Delete build/ and reconfigure |
| Output binary runs on host instead of failing | macOS / Windows | Wrong toolchain selected | Check file <output> (macOS) or llvm-readelf.exe -h <output> (Windows); it must report ARM aarch64 / machine AArch64 |