cc1:错误:无法识别的命令行选项‘-std=c11’

cc1:错误:无法识别的命令行选项‘-std=c11’

我在编译cc1: error: unrecognized command line option '-std=c11'项目时遇到此错误。所有相关问题都建议使用 4.7 以上的 gcc,但我已经有 4.7 以上的 gcc。这是详细信息

gcc version 6.3.0 20170519 (Ubuntu/Linaro 6.3.0-18ubuntu2~16.04)

我正在尝试编译这个https://github.com/rhdunn/espeak/tree/master/android. 问题发生在这个文件中https://github.com/rhdunn/espeak/blob/master/android/jni/Android.mk而 ndk-build。

这就是我正在做的事情

-vbox:~/eSpeak/espeak-master/android/jni$ ndk-build
Compile mips   : ttsespeak <= case.c
cc1: error: unrecognized command line option '-std=c11'
make: *** [/home/apertium/eSpeak/espeak-master/android/obj/local/mips/objs/ttsespeak/__/__/src/ucd-tools/src/case.o] Error 1

ndk-build V=1 命令将给出以下日志。

apertium@ap-vbox:~/eSpeak/espeak-master/android/jni$ ndk-build V=1 
rm -f /home/apertium/eSpeak/espeak-master/android/libs/armeabi/lib*.so /home/apertium/eSpeak/espeak-master/android/libs/armeabi-v7a/lib*.so /home/apertium/eSpeak/espeak-master/android/libs/mips/lib*.so /home/apertium/eSpeak/espeak-master/android/libs/x86/lib*.so 
rm -f /home/apertium/eSpeak/espeak-master/android/libs/armeabi/gdbserver /home/apertium/eSpeak/espeak-master/android/libs/armeabi-v7a/gdbserver /home/apertium/eSpeak/espeak-master/android/libs/mips/gdbserver /home/apertium/eSpeak/espeak-master/android/libs/x86/gdbserver 
rm -f /home/apertium/eSpeak/espeak-master/android/libs/armeabi/gdb.setup /home/apertium/eSpeak/espeak-master/android/libs/armeabi-v7a/gdb.setup /home/apertium/eSpeak/espeak-master/android/libs/mips/gdb.setup /home/apertium/eSpeak/espeak-master/android/libs/x86/gdb.setup 
Compile mips : ttsespeak <= case.c 
/home/apertium/android-ndk-x86/android-ndk-r9/toolchains/mipsel-linux-android-4.6/prebuilt/linux-x86/bin/mipsel-linux-android-gcc -MMD -MP -MF /home/apertium/eSpeak/espeak-master/android/obj/local/mips/objs/ttsespeak/__/__/src/ucd-tools/src/case.o.d -fpic -fno-strict-aliasing -finline-functions -ffunction-sections -funwind-tables -fmessage-length=0 -fno-inline-functions-called-once -fgcse-after-reload -frerun-cse-after-loop -frename-registers -no-canonical-prefixes -O2 -g -DNDEBUG -fomit-frame-pointer -funswitch-loops -finline-limit=300 -I/home/apertium/eSpeak/espeak-master/android/jni/include -I/home/apertium/eSpeak/espeak-master/android/jni/../../src/ucd-tools/src/include -I/home/apertium/eSpeak/espeak-master/android/jni/../../src/include -I/home/apertium/eSpeak/espeak-master/android/jni -DANDROID -std=c11 -DINCLUDE_KLATT -DINCLUDE_SONIC -Wa,--noexecstack -Wformat -Werror=format-security -I/home/apertium/android-ndk-x86/android-ndk-r9/platforms/android-14/arch-mips/usr/include -c /home/apertium/eSpeak/espeak-master/android/jni/../../src/ucd-tools/src/case.c -o /home/apertium/eSpeak/espeak-master/android/obj/local/mips/objs/ttsespeak/__/__/src/ucd-tools/src/case.o 
cc1: error: unrecognized command line option '-std=c11' 
make: *** [/home/apertium/eSpeak/espeak-master/android/obj/local/mips/objs/ttsespeak/__/__/src/ucd-tools/src/case.o] Error 1

任何帮助是极大的赞赏。

答案1

在...的帮助下大卫·福斯特我发现上述错误是由于 Android NDK 包含自己的 C 编译器,所以我的 NDK 使用的是 GCC 4.6,它不支持 C11。所以我将我的 NDK 更新至 r16并导致以下错误。

root@ap-vbox:~/eSpeak/espeak-master# make V=1 apk-release
cd android && ndk-build
/home/apertium/android-ndk-r-16/android-ndk-r16/prebuilt/linux-x86_64/bin/python: 10: /home/apertium/android-ndk-r-16/android-ndk-r16/prebuilt/linux-x86_64/bin/python: Syntax error: word unexpected (expecting ")")
/home/apertium/android-ndk-r-16/android-ndk-r16/prebuilt/linux-x86_64/bin/python: 10: /home/apertium/android-ndk-r-16/android-ndk-r16/prebuilt/linux-x86_64/bin/python: Syntax error: word unexpected (expecting ")")
Android NDK: WARNING: APP_PLATFORM android-14 is higher than android:minSdkVersion 1 in ./AndroidManifest.xml. NDK binaries will *not* be comptible with devices older than android-14. See https://android.googlesource.com/platform/ndk/+/master/docs/user/common_problems.md for more information.    
/home/apertium/android-ndk-r-16/android-ndk-r16/prebuilt/linux-x86_64/bin/python: 10: /home/apertium/android-ndk-r-16/android-ndk-r16/prebuilt/linux-x86_64/bin/python: Syntax error: word unexpected (expecting ")")
make[1]: Entering directory `/home/apertium/eSpeak/espeak-master/android'
rm -f ./libs/arm64-v8a/* ./libs/armeabi/* ./libs/armeabi-v7a/* ./libs/mips/* ./libs/mips64/* ./libs/x86/* ./libs/x86_64/*
rm -f ./libs/arm64-v8a/gdbserver ./libs/armeabi/gdbserver ./libs/armeabi-v7a/gdbserver ./libs/mips/gdbserver ./libs/mips64/gdbserver ./libs/x86/gdbserver ./libs/x86_64/gdbserver
rm -f ./libs/arm64-v8a/gdb.setup ./libs/armeabi/gdb.setup ./libs/armeabi-v7a/gdb.setup ./libs/mips/gdb.setup ./libs/mips64/gdb.setup ./libs/x86/gdb.setup ./libs/x86_64/gdb.setup
[mips] Compile        : ttsespeak <= case.c
/home/apertium/android-ndk-r-16/android-ndk-r16/toolchains/llvm/prebuilt/linux-x86_64/bin/clang -MMD -MP -MF ./obj/local/mips/objs/ttsespeak/__/__/src/ucd-tools/src/case.o.d -gcc-toolchain /home/apertium/android-ndk-r-16/android-ndk-r16/toolchains/mips64el-linux-android-4.9/prebuilt/linux-x86_64 -target mipsel-none-linux-android -fpic -ffunction-sections -funwind-tables -fstack-protector-strong -fmessage-length=0 -Wno-invalid-command-line-argument -Wno-unused-command-line-argument -no-canonical-prefixes  -g -mips32 -O2 -DNDEBUG  -Ijni/include -Ijni/../../src/ucd-tools/src/include -Ijni/../../src/include -Ijni   -DANDROID -std=c11 -DINCLUDE_KLATT -DINCLUDE_SONIC -D__ANDROID_API__=14 -Wa,--noexecstack -Wformat -Werror=format-security  --sysroot /home/apertium/android-ndk-r-16/android-ndk-r16/sysroot -isystem /home/apertium/android-ndk-r-16/android-ndk-r16/sysroot/usr/include/mipsel-linux-android -c  jni/../../src/ucd-tools/src/case.c -o ./obj/local/mips/objs/ttsespeak/__/__/src/ucd-tools/src/case.o
/home/apertium/android-ndk-r-16/android-ndk-r16/toolchains/llvm/prebuilt/linux-x86_64/bin/clang: 1: /home/apertium/android-ndk-r-16/android-ndk-r16/toolchains/llvm/prebuilt/linux-x86_64/bin/clang: Syntax error: ")" unexpected
make[1]: *** [obj/local/mips/objs/ttsespeak/__/__/src/ucd-tools/src/case.o] Error 2
make[1]: Leaving directory `/home/apertium/eSpeak/espeak-master/android'
make: *** [jni] Error 2

我为此使用了虚拟盒。但是当我尝试在安装了 ubuntu 的系统上编译相同内容时,没有任何问题。一切都顺利进行并编译完成。所以我猜问题出在我的虚拟盒上。

相关内容