简体   繁体   English

NDK中的未定义参考错误

[英]Undefined reference error in NDK

I am trying to compile unrar for Android but getting some undefined reference error . 我正在尝试为Android编译unrar ,但遇到一些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 . 我试图从现有的makefile编写Android.mk

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 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. CommandData声明中cmddata.hpp和实施cmddata.cpp文件。 rar.hpp also includes cmddata.hpp But why it's complaining that functions are undefined. rar.hpp还包含cmddata.hpp但是为什么会抱怨函数未定义。

The source code you found is not complete, and does not carry official claims to compile, especially under Android. 您找到的源代码不完整,并且没有官方要求进行编译,尤其是在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 将Android.mk完全按照您的问题放入jni目录
  4. untar unrarsrc-5.3.6.tar.gz to jni/unrar 将unrarsrc-5.3.6.tar.gz解压缩为jni / unrar
  5. add one line #88 in jni/unrar/rar.hpp : #undef _ANDROID jni / unrar / rar.hpp中添加一行#88: #undef _ANDROID
  6. create empty file jni/com_unrar_jni.cpp 创建空文件jni / com_unrar_jni.cpp
  7. run ndk-build APP_CFLAGS="-Dgetpass\\(a\\)=a" APP_STL=stlport_static c++_static may work, too ) 运行ndk-build APP_CFLAGS="-Dgetpass\\(a\\)=a" APP_STL=stlport_static c ++ _ static也可以

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

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