Code Bye

android studio编译C++问题

筒子们,讨教个问题
本人的环境是ubunt, Android Studio,现在要写个带native的应用
本人的C++代码中有这么一句:
#include <string>
在Application.mk中有这么一句
APP_STL := gnustl_static
然后在命令行模式下运行ndk-build,能正常编译通过并生成好相关的.so到对应的目录下去
然后用Android Studio编译生成apk,就报如下错误,讨教各位,有什么解决办法么?谢谢先
In file included from /home/leo/source/ics_apple/packages/apps/MusicToolbox/MusicToolbox/src/main/jni/SoundStretch/main.cpp:43:0:
/home/leo/source/ics_apple/packages/apps/MusicToolbox/MusicToolbox/src/main/jni/SoundStretch/RunParameters.h:43:18: fatal error: string: No such file or directory
compilation terminated.
make: *** [/home/leo/source/ics_apple/packages/apps/MusicToolbox/MusicToolbox/build/ndk/arm/debug/obj/local/armeabi/objs/MusicToolbox//home/leo/source/ics_apple/packages/apps/MusicToolbox/MusicToolbox/src/main/jni/SoundStretch/main.o] Error 1
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task “:MusicToolbox:compileArmDebugNdk”.
> com.android.ide.common.internal.LoggedErrorException: Failed to run command:
/home/leo/android-ndk-r9c/ndk-build NDK_PROJECT_PATH=null APP_BUILD_SCRIPT=/home/leo/source/ics_apple/packages/apps/MusicToolbox/MusicToolbox/build/ndk/arm/debug/Android.mk APP_PLATFORM=android-19 NDK_OUT=/home/leo/source/ics_apple/packages/apps/MusicToolbox/MusicToolbox/build/ndk/arm/debug/obj NDK_LIBS_OUT=/home/leo/source/ics_apple/packages/apps/MusicToolbox/MusicToolbox/build/ndk/arm/debug/lib APP_ABI=armeabi
Error Code:
2
Output:
In file included from /home/leo/source/ics_apple/packages/apps/MusicToolbox/MusicToolbox/src/main/jni/SoundStretch/main.cpp:43:0:
/home/leo/source/ics_apple/packages/apps/MusicToolbox/MusicToolbox/src/main/jni/SoundStretch/RunParameters.h:43:18: fatal error: string: No such file or directory
compilation terminated.
make: *** [/home/leo/source/ics_apple/packages/apps/MusicToolbox/MusicToolbox/build/ndk/arm/debug/obj/local/armeabi/objs/MusicToolbox//home/leo/source/ics_apple/packages/apps/MusicToolbox/MusicToolbox/src/main/jni/SoundStretch/main.o] Error 1
* Try:
Run with –stacktrace option to get the stack trace. Run with –info or –debug option to get more log output.
解决方案

CodeBye 版权所有丨如未注明 , 均为原创丨本网站采用BY-NC-SA协议进行授权 , 转载请注明android studio编译C++问题