ndk-build with sqlite library error - android

I am creating an android application which is having native C code along with sqlite database.
When I do a ndk-build from my jni folder,I am getting the following error.
undefined reference to `sqlite3_open'
peard.c:(.text+0x588): undefined reference to `sqlite3_exec'
peard.c:(.text+0x5f8): undefined reference to `sqlite3_exec'
peard.c:(.text+0x668): undefined reference to `sqlite3_exec'
peard.c:(.text+0x6d8): undefined reference to `sqlite3_prepare_v2'
peard.c:(.text+0x720): undefined reference to `sqlite3_column_count'
peard.c:(.text+0x734): undefined reference to `sqlite3_step'
peard.c:(.text+0x774): undefined reference to `sqlite3_column_text'
peard.c:(.text+0x78c): undefined reference to `sqlite3_column_name'
peard.c:(.text+0x800): undefined reference to `sqlite3_close'
I tried to run along with -lsqlite3 command also,but doesn't work.
Thanks.

I solved the problem by adding sqlite3.c source file to my dependency files list in my Android.mk file.Special thanks to hirschhomsalz.
Narain.

You need to build or install sqlite3 (and all other non standard libraries you project depends on) for android, and the build your project with the -L and -I parameters pointing to the arm version of you sqlite libraries and headers.

Related

too many undefined reference errors for OpenCV in NDK coding

i get many undefined reference errors when i code opencv under android NDK, such as:
system.cpp:(.text.unlikely._ZNSs4_Rep10_M_disposeERKSaIcE.part.5+0x1c):
undefined reference to `std::string::_Rep::_M_destroy(std::allocator
const&)'
G:/AndroidProjects/SprayingPrjJNI/app/src/main/cpp/../jniLibs/arm64-v8a/libopencv_core.a(system.cpp.o):
In function `void std::_Destroy(std::string*, std::string*,
std::allocator&) [clone .isra.88]':
system.cpp:(.text.unlikely._ZSt8_DestroyIPSsSsEvT_S1_RSaIT0_E.isra.88+0x18):
undefined reference to `std::string::_Rep::_S_empty_rep_storage'
system.cpp:(.text.unlikely._ZSt8_DestroyIPSsSsEvT_S1_RSaIT0_E.isra.88+0x2c):
undefined reference to `std::string::_Rep::_S_empty_rep_storage'
..................
i really dont know how to fix these errors, please help me, thanks
See NDK - problems after GNUSTL has been removed from the NDK (revision r18).
But if you don't have very strong reasons to stay with the old version of OpenCV, the easiest approach is to switch to prebuilt OpenCV 4.01 which is compatible with NDK r19.

errors while compiling the MuPDF for android platform

I want to develop and android application which will help annotate the PDF files in android. Thus, I am using MuPDF to read and Parse the PDF files in android. I am trying to build it as specified in http://www.mupdf.com/doc/how-to-build-mupdf-for-android , but I have encountered the following error:
C:/Android-NDK/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/libmupdfcore.a(image.o): in function fz_decomp_image_from_stream:jni/../../../source/fitz/image.c:182: error: undefined reference to 'fz_unpack_tile'
C:/Android-NDK/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/libmupdfcore.a(image.o): in function fz_decomp_image_from_stream:jni/../../../source/fitz/image.c:193: error: undefined reference to 'fz_decode_indexed_tile'
C:/Android-NDK/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/libmupdfcore.a(image.o): in function fz_decomp_image_from_stream:jni/../../../source/fitz/image.c:200: error: undefined reference to 'fz_decode_tile'
C:/Android-NDK/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/libmupdfcore.a(load-tiff.o): in function fz_load_tiff:jni/../../../source/fitz/load-tiff.c:804: error: undefined reference to 'fz_unpack_tile'
C:/Android-NDK/android-ndk/toolchains/arm-linux-androideabi-4.6/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.6/../../../../arm-linux-androideabi/bin/ld.exe: ./obj/local/armeabi-v7a/libmupdfcore.a(load-png.o): in function fz_load_png:jni/../../../source/fitz/load-png.c:567: error: undefined reference to 'fz_unpack_tile'
On analyzing the first error, I understood that fz_unpack_tile, fz_decode_tile, fz_decode_indexed_tile are defined in fitz/draw-unpack.c
Now, I am not sure of how to continue from here
You asked this on irc yesterday, and I suggested that you do a complete clean, then rebuild from scratch capturing the logs and post them somewhere.
The code as supplied in git builds just fine in android for us. Without more information, no one is going to be able to help you.

How can I compile the swiften XMPP library for usage with Android?

I tried to compile swiften (a XMPP client library) into a lib for Android JNI but failed. Is there anyone successed? Any suggestion would be appreciated.
I compiled swiften as follow steps:
Downloaded swiften from http://swift.im/git/swift/commit/?id=13a3f7812520d44e374d7c391daf2128335ac067
Do as follow document: http://swift.im/git/swift/commit/?h=sandbox/tobias/android&id=b8e69ea59b471e1aff9c8db06aceb7108db0657b
since I only need swiften, so I compile as: ./scons Swiften target=android toolchain=/home/XXX/toolchain
Then I got follow problems:
can't find cryptlib.c, so I downloaded openssl and this fixed.
can't find arpa/nameser_compat.h. Then I copied this header files from /usr/include to tool-chain, and added #define BSD 199307 at the begining.
can't find the declarations of res_init(), res_query(), dn_expand(), dn_skipname(). So I added the declarations.
And finally I got libSwiften.a which the size is 260M. And there are about 200 link errors:
AR Swiften/libSwiften.a
RANLIB Swiften/libSwiften.a
LINK Swiften/Examples/BenchTool/BenchTool
3rdParty/OpenSSL/openssl/crypto/objects/obj_dat.c:489: error: undefined reference to 'BUF_strlcpy'
3rdParty/OpenSSL/openssl/crypto/objects/obj_dat.c:579: error: undefined reference to 'BUF_strlcpy'
3rdParty/OpenSSL/openssl/crypto/objects/obj_dat.c:601: error: undefined reference to 'BUF_strlcpy'
3rdParty/OpenSSL/openssl/crypto/bio/bss_file.c:368: error: undefined reference to 'BUF_strlcpy'
3rdParty/OpenSSL/openssl/crypto/err/err.c:1104: error: undefined reference to 'BUF_strlcat'
3rdParty/OpenSSL/openssl/crypto/x509v3/v3_enum.c:94: error: undefined reference to 'BUF_strdup'
3rdParty/OpenSSL/openssl/crypto/x509v3/v3_purp.c:199: error: undefined reference to 'BUF_strdup'
3rdParty/OpenSSL/openssl/crypto/x509v3/v3_purp.c:200: error: undefined reference to 'BUF_strdup'
some more......

undefined reference to `std::basic_string<wchar_t,

I am trying to compile my c++ files using cygwin.
\Files are compiled but linking time errors occur
These kind of errors...
undefined reference to `std::basic_string<wchar_t, std::char_traits<wchar_t>, std::allocator<wchar_t> >::size() const'
and some more errors like
undefined reference to `sqlite3_mprintf'
undefined reference to `sqlite3_exec'
undefined reference to `sqlite3_free'
undefined reference to `sqlite3_free'
undefined reference to `sqlite3_free'
undefined reference to `sqlite3_exec'
please help me out?
Thank you.
It looks like the standard C++ library is not getting linked in. Are you linking your code with g++, gcc or ld? If using the first, that library gets linked in automatically, but not if you're using the other two.
For the errors about sqlite3, you need to add -lsqlite3 to the link command (assuming you have it installed, of course).

Error undefined reference in build muPDF for android (need help)

this is sample error in cygwin
C:/mupdf-0.8.165/android/jni/../../mupdf/pdf_nametree.c:111:
undefined reference to `fz_array_get'
C:/mupdf-0.8.165/android/jni/../../mupdf/pdf_nametree.c:112:
undefined reference to `fz_is_string'
C:/mupdf-0.8.165/android/jni/../../mupdf/pdf_nametree.c:115:
undefined reference to `fz_dict_put'
C:/mupdf-0.8.165/android/jni/../../mupdf/pdf_nametree.c:116:
undefined reference to `fz_drop_obj'
In pdf_nametree include fitz.h
actually I check the function fz_array_get in fitz.h already
I have no idea now
Can anybody point me to the right direction or give me a another way
thx
sasara
Looks like your %path% variable (DOS) was not correctly translated to the $PATH (Cygwin) variable....
You need to install both the Android SDK as well as the Android NDK. Then you need to add both <sdk-install-dir>\tools and <ndk-install-dir> to your %path% variable.
Also, you need Cygwin v1.7 or greater on Windows.
Then, look here: http://groups.google.com/group/android-ndk/msg/b385e47e1484c2d4 for 2 fixes which deal with bugs that occur for automatic conversion from DOS format path variables to Cygwin format path variables.

Categories

Resources