在window下载的android NDK解压后,可以用如下命令,安装NDK独立编译工具。这样再用命令时不用带一把参数了。
"D:\Program Files\python27\python" make_standalone_toolchain.py --arch arm --api=9 --install-dir=d:/test --force
其中python27去下了安装就好。
然后简单的
D:\test\bin\arm-linux-androideabi-gcc -o test test.cpp 或
D:\test\bin\clang -o test test.cpp
都可以编出一个简单的示例。我用的是clang 编出的好似用不支持arm6以下的。只能用于armv7以上。
如果需要支持arm6下以如以改写bin目录下的clang.cmd方件。
@echo off
if "%1" == "-cc1" goto :L
rem %~dp0\clang38.exe -target armv7a-none-linux-androideabi --sysroot %~dp0\..\sysroot %*
%~dp0\clang38.exe -target armv5te-none-linux-androideabi --sysroot %~dp0\..\sysroot %*
if ERRORLEVEL 1 exit /b 1
goto :done
:L
rem target/triple already spelled out.
%~dp0\clang38.exe %*
if ERRORLEVEL 1 exit /b 1
:done
又或者用带参数调用
\clang38.exe -target armv5t