Closed robin2046 closed 3 years ago
Fixed.
Thanks a lot for the quick fix.
I managed to build the library release with cargo-ndk successfully (both .a and .so are generated for the common 4 archs). But when I tried to build it in my app with 32bit Android NDK toolchain I got another error:
src/main/cpp/gifski/libs/armeabi-v7a/libgifski.a(quantize.o):quantize.c:function colormap_image_floyd_steinberg: error: undefined reference to 'rand'
clang++: error: linker command failed with exit code 1 (use -v to see invocation)
ninja: build stopped: subcommand failed.
Trying to link with 32bit shared library libgifski.so gave the same error.
I googled a little bit and found it seems to be an infamous issue, a simple fix could be adding #include "stdlib.h" to those error files. However, how can I do it to quantize.c in this cargo build system? I am totally new to this fancy build system.
Please help to point out a solution, thanks a lot.
The rand()
call is from here:
which already includes <stdlib.h>
.
It's built using this script:
but this is just a wrapper that in the end calls your regular C compiler (whatever it finds in the CC
env var).
Thanks a lot for this comments, I finally get it built successfully by change NDK api level to 19 for 32bit targets.
By the way, I found with your new commit which updates the Rust gif crate, the output GIF is not correctly encoded. I always get decode error with the generated GIF (neither by my test code using libgifski.a, or by the executable binary generated directly by cargo build)
Use giflib to decode it and get error at:
DGifDecompressLine()
if (CrntCode == EOFCode) {
/* Note however that usually we will not be here as we will stop
* decoding as soon as we got all the pixel, or EOF code will
* not be read at all, and DGifGetLine/Pixel clean everything. */
GifFile->Error = D_GIF_ERR_EOF_TOO_SOON;
I also tried built an executable on my MACOS with the same PNG files, I also get un-decodable (with default preview app or Chrome) GIF results. I have to revert to 1.2.4 to get a correct result GIF. Please check if the new update breaks the GIF encoding routine. Thanks.
Head is at
Tried to build with
cargo ndk --platform 21 --target i686-linux-android build --lib --release
And got following error:
64bit toolchain worked without any issue.