質問

I am using https://github.com/lilac/Android-ImageMagick to build an ImageMagick library for Android. When trying to ndk-build ImageMagick I end up with the below errors.

primary0:AndroidMagickActivity primary0$ ~/ndk/ndk-build 
SharedLibrary  : libandroid-magick.so
/Users/primary0/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/libcoders.a(jpeg.o): in function ReadJPEGImage:jni/../ndk-modules/ImageMagick-6.7.3-0/coders/jpeg.c:988: error: undefined reference to 'jpeg_std_error'
/Users/primary0/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/libcoders.a(jpeg.o): in function ReadJPEGImage:jni/../ndk-modules/ImageMagick-6.7.3-0/coders/jpeg.c:995: error: undefined reference to 'jpeg_destroy_decompress'
/Users/primary0/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/libcoders.a(jpeg.o): in function ReadJPEGImage:jni/../ndk-modules/ImageMagick-6.7.3-0/coders/jpeg.c:1004: error: undefined reference to 'jpeg_CreateDecompress'
/Users/primary0/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/libcoders.a(jpeg.o): in function ReadJPEGImage:jni/../ndk-modules/ImageMagick-6.7.3-0/coders/jpeg.c:1006: error: undefined reference to 'jpeg_set_marker_processor'
/Users/primary0/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/libcoders.a(jpeg.o): in function ReadJPEGImage:jni/../ndk-modules/ImageMagick-6.7.3-0/coders/jpeg.c:1007: error: undefined reference to 'jpeg_set_marker_processor'
/Users/primary0/ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/darwin-x86/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld: ./obj/local/armeabi/libcoders.a(jpeg.o): in function ReadJPEGImage:jni/../ndk-modules/ImageMagick-6.7.3-0/coders/jpeg.c:1008: error: undefined reference to 'jpeg_set_marker_
.
.
.
collect2: ld returned 1 exit status 
make: *** [obj/local/armeabi/libandroid-magick.so] Error 1
primary0:AndroidMagickActivity primary0$ 

The header file that defines the constants listed in the error is included jpeg.c

#include "jpeglib.h"

Any of you guys have an idea why I'm getting the undefined reference error?

役に立ちましたか?

解決

The linker is not looking for "constants" it's looking for jump addresses to call functions. Your code obviously uses functions which are not available in the object code. This can have various reasons. Either you did not tell the compiler to use a library which is availabe or (in your case more likely) you did not tell the compiler that jpeg.c also needs to be compiled for this shared object. But this is difficult to diagnose without seeing the makefile.

Taking a short look at the ndk-modules folder of the git repository I get the feeling you need to build multiple modules. Maybe you just do it in the wrong order. Try building jpeg first.

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top