0

I am trying to compile unrar for Android but getting some undefined reference error. I am stuck here for couple of days but can't find the exact problem. I tried to write Android.mk from existing makefile.

Error

jni/unrar/rar.cpp:104: error: undefined reference to 'CommandData::ParseCommandLine(bool, int, char**)'
jni/unrar/rar.cpp:107: error: undefined reference to 'CommandData::ReadConfig()'
jni/unrar/rar.cpp:108: error: undefined reference to 'CommandData::ParseEnvVar()'
jni/unrar/rar.cpp:110: error: undefined reference to 'CommandData::ParseCommandLine(bool, int, char**)'

Android.mk

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
UNRAR_PATH := $(LOCAL_PATH)/unrar
LOCAL_MODULE    := unrar-jni

LOCAL_SRC_FILES := com_unrar_jni.cpp unrar/rar.cpp unrar/strlist.cpp unrar/strfn.cpp unrar/pathfn.cpp unrar/smallfn.cpp unrar/global.cpp unrar/file.cpp unrar/filefn.cpp unrar/filcreat.cpp \
    unrar/archive.cpp unrar/arcread.cpp unrar/unicode.cpp unrar/system.cpp unrar/isnt.cpp unrar/crypt.cpp unrar/crc.cpp unrar/rawread.cpp unrar/encname.cpp \
    unrar/resource.cpp unrar/match.cpp unrar/timefn.cpp unrar/rdwrfn.cpp unrar/consio.cpp unrar/options.cpp unrar/errhnd.cpp unrar/rarvm.cpp unrar/secpassword.cpp \
    unrar/rijndael.cpp unrar/getbits.cpp unrar/sha1.cpp unrar/sha256.cpp unrar/blake2s.cpp unrar/hash.cpp unrar/extinfo.cpp unrar/extract.cpp unrar/volume.cpp \
    unrar/list.cpp unrar/find.cpp unrar/unpack.cpp unrar/headers.cpp unrar/threadpool.cpp unrar/rs16.cpp unrar/cmddata.cpp unrar/ui.cpp \
    unrar/filestr.cpp unrar/recvol.cpp unrar/rs.cpp unrar/scantree.cpp unrar/qopen.cpp 

LOCAL_CFLAGS := -O2
LOCAL_CPPFLAGS := -fexceptions -D_FILE_OFFSET_BITS=64 -D_LARGEFILE_SOURCE
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)

CommandData declares in cmddata.hpp and implemented in cmddata.cpp file. rar.hpp also includes cmddata.hpp But why it's complaining that functions are undefined.

6
  • Something is wrong with your link. ui.cpp does not exist in the tar file. Commented Nov 11, 2015 at 21:35
  • @AlexCohn I have fixed link. Commented Nov 12, 2015 at 6:40
  • 1
    The source code you found is not complete, and does not carry official claims to compile, especially under Android. The file GUI/arajni.hpp is simply missing from the tar. The function JniCharToWide() is never declared, and so on. I could create libunrar-jni.so only after manually editing rar.hpp file: I added #undef _ANDROID before the #ifdef _ANDROID on line 89. The command line: ndk-build APP_STL=c++_static Commented Nov 12, 2015 at 9:01
  • @AlexCohn Yes, I manually comment all #ifdef _ANDROID code section. They used jni callback but I think it's not required for now. Commented Nov 12, 2015 at 9:55
  • I found that all _ANDROID results in bad build. Try the single change as I suggested above. Commented Nov 12, 2015 at 9:58

1 Answer 1

1

The source code you found is not complete, and does not carry official claims to compile, especially under Android. But the following steps can get you started:

  1. open new directory, open command line to that directory.
  2. mkdir jni
  3. put the Android.mk exactly as you have in your question to jni directory
  4. untar unrarsrc-5.3.6.tar.gz to jni/unrar
  5. add one line #88 in jni/unrar/rar.hpp: #undef _ANDROID
  6. create empty file jni/com_unrar_jni.cpp
  7. run ndk-build APP_CFLAGS="-Dgetpass\(a\)=a" APP_STL=stlport_static c++_static may work, too)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.