简体   繁体   English

Android NDK R14的SDL2示例构建错误

[英]SDL2 sample build error with android ndk r14

I have tested to build the sample in SDL2 source (2.0.5) on my ubuntu 16.04 machine. 我已经测试过在ubuntu 16.04机器上以SDL2源(2.0.5)构建示例。

According to https://wiki.libsdl.org/Android , I installed android sdk and ndk r14 and setup my environment variables. 根据https://wiki.libsdl.org/Android ,我安装了android sdk和ndk r14并设置了环境变量。

But I have failed to build with following command in "Simple Build" chapter. 但是在“简单构建”一章中,我无法使用以下命令进行构建。

cd /usr/src/SDL2/build-scripts/
 ./androidbuild.sh org.libsdl.testgles ../test/testgles.c

It makes following error. 它导致以下错误。

Error: The project either has no target set or the target is invalid.
Please provide a --target to the 'android update' command.
[armeabi] Compile thumb  : SDL2 <= SDL.c
[armeabi] Compile thumb  : SDL2 <= SDL_assert.c
[armeabi] Compile thumb  : SDL2 <= SDL_error.c
[armeabi] Compile thumb  : SDL2 <= SDL_hints.c
[armeabi] Compile thumb  : SDL2 <= SDL_log.c
[armeabi] Compile thumb  : SDL2 <= SDL_audio.c
[armeabi] Compile thumb  : SDL2 <= SDL_audiocvt.c
[armeabi] Compile thumb  : SDL2 <= SDL_audiodev.c
[armeabi] Compile thumb  : SDL2 <= SDL_audiotypecvt.c
[armeabi] Compile thumb  : SDL2 <= SDL_mixer.c
[armeabi] Compile thumb  : SDL2 <= SDL_wave.c
fatal error: error in backend: Cannot select: 0x43bd850: i32 = ARMISD::SSAT 0x43acfc0, Constant:i32<15>
  0x43acfc0: i32 = add 0x43ac770, 0x43bd690
    0x43ac770: i32 = sra 0x43bda80, Constant:i32<8>
      0x43bda80: i32 = add 0x43ac460, 0x43ad2d0
        0x43ac460: i32 = add 0x4399d70, 0x43bdf50
          0x4399d70: i32 = mul 0x43ad180, 0x439a160
            0x43ad180: i32,ch = load<LD2[%15](tbaa=<0x4229ab8>), sext from i16> 0x42e7b60, 0x43acaf0, undef:i32
              0x43acaf0: i32 = add 0x4399bb0, Constant:i32<2>
                0x4399bb0: i32,ch = CopyFromReg 0x42e7b60, Register:i32 %vreg2
                  0x439a5c0: i32 = Register %vreg2
                0x4399fa0: i32 = Constant<2>
              0x43aca10: i32 = undef
            0x439a160: i32,ch = load<LD2[%12](tbaa=<0x42638a8>), sext from i16> 0x42e7b60, 0x4399ec0, undef:i32
              0x4399ec0: i32 = add 0x43ac7e0, Constant:i32<6>
                0x43ac7e0: i32,ch = CopyFromReg 0x42e7b60, Register:i32 %vreg0
                  0x43bdd20: i32 = Register %vreg0
                0x439a710: i32 = Constant<6>
              0x43aca10: i32 = undef
          0x43bdf50: i32 = mul 0x43ac4d0, 0x439a470
            0x43ac4d0: i32,ch = load<LD2[%2](tbaa=<0x4229ab8>), sext from i16> 0x42e7b60, 0x4399bb0, undef:i32
              0x4399bb0: i32,ch = CopyFromReg 0x42e7b60, Register:i32 %vreg2
                0x439a5c0: i32 = Register %vreg2
              0x43aca10: i32 = undef
            0x439a470: i32,ch = load<LD2[%6](tbaa=<0x42638a8>), sext from i16> 0x42e7b60, 0x439a080, undef:i32
              0x439a080: i32 = add 0x43ac7e0, Constant:i32<4>
                0x43ac7e0: i32,ch = CopyFromReg 0x42e7b60, Register:i32 %vreg0
                  0x43bdd20: i32 = Register %vreg0
                0x43ace70: i32 = Constant<4>
              0x43aca10: i32 = undef
        0x43ad2d0: i32 = srl 0x43aca80, Constant:i32<24>
          0x43aca80: i32 = sra 0x43ac460, Constant:i32<31>
            0x43ac460: i32 = add 0x4399d70, 0x43bdf50
              0x4399d70: i32 = mul 0x43ad180, 0x439a160
                0x43ad180: i32,ch = load<LD2[%15](tbaa=<0x4229ab8>), sext from i16> 0x42e7b60, 0x43acaf0, undef:i32
                  0x43acaf0: i32 = add 0x4399bb0, Constant:i32<2>


                  0x43aca10: i32 = undef
                0x439a160: i32,ch = load<LD2[%12](tbaa=<0x42638a8>), sext from i16> 0x42e7b60, 0x4399ec0, undef:i32
                  0x4399ec0: i32 = add 0x43ac7e0, Constant:i32<6>


                  0x43aca10: i32 = undef
              0x43bdf50: i32 = mul 0x43ac4d0, 0x439a470
                0x43ac4d0: i32,ch = load<LD2[%2](tbaa=<0x4229ab8>), sext from i16> 0x42e7b60, 0x4399bb0, undef:i32
                  0x4399bb0: i32,ch = CopyFromReg 0x42e7b60, Register:i32 %vreg2

                  0x43aca10: i32 = undef
                0x439a470: i32,ch = load<LD2[%6](tbaa=<0x42638a8>), sext from i16> 0x42e7b60, 0x439a080, undef:i32
                  0x439a080: i32 = add 0x43ac7e0, Constant:i32<4>


                  0x43aca10: i32 = undef
            0x43bd700: i32 = Constant<31>
          0x439a550: i32 = Constant<24>
      0x43acd20: i32 = Constant<8>
    0x43bd690: i32 = mul 0x43ad260, 0x43bdd90
      0x43ad260: i32,ch = load<LD2[%24](tbaa=<0x42638a8>), zext from i16> 0x42e7b60, 0x43bdc40, undef:i32
        0x43bdc40: i32 = add 0x43ac7e0, Constant:i32<2>
          0x43ac7e0: i32,ch = CopyFromReg 0x42e7b60, Register:i32 %vreg0
            0x43bdd20: i32 = Register %vreg0
          0x4399fa0: i32 = Constant<2>
        0x43aca10: i32 = undef
      0x43bdd90: i32 = ARMISD::CMOV 0x439a390, 0x439a940, Constant:i32<0>, Register:i32 %CPSR, 0x43ac5b0
        0x439a390: i32 = add 0x439a940, Constant:i32<-16>
          0x439a940: i32 = AssertZext 0x439a6a0, ValueType:ch:i8
            0x439a6a0: i32,ch = CopyFromReg 0x42e7b60, Register:i32 %vreg1
              0x43ace00: i32 = Register %vreg1
          0x43ac700: i32 = Constant<-16>
        0x439a940: i32 = AssertZext 0x439a6a0, ValueType:ch:i8
          0x439a6a0: i32,ch = CopyFromReg 0x42e7b60, Register:i32 %vreg1
            0x43ace00: i32 = Register %vreg1
        0x43bdbd0: i32 = Constant<0>
        0x43ac620: i32 = Register %CPSR
        0x43ac5b0: glue = ARMISD::CMPZ 0x439a2b0, Constant:i32<0>
          0x439a2b0: i32 = and 0x439a940, Constant:i32<8>
            0x439a940: i32 = AssertZext 0x439a6a0, ValueType:ch:i8
              0x439a6a0: i32,ch = CopyFromReg 0x42e7b60, Register:i32 %vreg1
                0x43ace00: i32 = Register %vreg1
            0x43acd20: i32 = Constant<8>
          0x43bdbd0: i32 = Constant<0>
  0x43acf50: i32 = Constant<15>
In function: MS_ADPCM_nibble
clang: error: clang frontend command failed with exit code 70 (use -v to see invocation)
Android clang version 3.8.275480  (based on LLVM 3.8.275480)
Target: armv5te-none-linux-android
Thread model: posix
InstalledDir: /home/idkiller/android-ndk-r14/toolchains/llvm/prebuilt/linux-x86_64/bin
clang: note: diagnostic msg: PLEASE submit a bug report to http://llvm.org/bugs/ and include the crash backtrace, preprocessed source, and associated run script.
clang: note: diagnostic msg: 
********************

PLEASE ATTACH THE FOLLOWING FILES TO THE BUG REPORT:
Preprocessed source(s) and associated run script(s) are located at:
clang: note: diagnostic msg: /tmp/SDL_wave-929d6f.c
clang: note: diagnostic msg: /tmp/SDL_wave-929d6f.sh
clang: note: diagnostic msg: 

********************
make: *** [obj/local/armeabi/objs/SDL2/src/audio/SDL_wave.o] Error 70
make: *** Waiting for unfinished jobs....
Buildfile: /home/idkiller/work17/SDL2-2.0.5/build/org.libsdl.testgles/build.xml

BUILD FAILED
/home/idkiller/work17/SDL2-2.0.5/build/org.libsdl.testgles/build.xml:56: sdk.dir is missing. Make sure to generate local.properties using 'android update project' or to inject it through the ANDROID_HOME environment variable.

Total time: 0 seconds
There was an error building the APK

I think first Error about 'android update' could be fix with doing update command by hand in project directory. 我认为关于“ android更新”的第一个错误可以通过在项目目录中手动执行更新命令来解决。

But I can't guess why LLVM backend makes this error on compiling SDL_wave.c 但是我无法猜测为什么LLVM后端在编译SDL_wave.c时会出现此错误

Is SDL2 not support to build with Clang 3.8 yet? SDL2是否不支持使用Clang 3.8进行构建?

I just have the same problem and I solve it, it feels so good! 我只是遇到了同样的问题,并且解决了,感觉真好!

I guess it was caused by compiler clang.exe. 我猜这是由编译器clang.exe引起的。

All you have to do is edit your application.mk(If you are using NDK_BUILD) 您所要做的就是编辑application.mk(如果使用的是NDK_BUILD)

add one line "NDK_TOOLCHAIN_VERSION=4.9(depends on you GCC version)" 添加一行“ NDK_TOOLCHAIN_VERSION = 4.9(取决于您的GCC版本)”

To add a bit to L.wc's answer try this: 要在L.wc的答案中添加一点,请尝试以下操作:

NDK_TOOLCHAIN_VERSION=4.9 ./androidbuild.sh org.libsdl.testgles ../test/testgles.c NDK_TOOLCHAIN_VERSION = 4.9 ./androidbuild.sh org.libsdl.testgles ../test/testgles.c

4.9 would be version of toolchain in your NDK installation. 4.9将是NDK安装中工具链的版本。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM