Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/209.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/c/58.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Android 链接器错误:未定义对“EVP cast5”ecb';_Android_C_Android Ndk_Openssl - Fatal编程技术网

Android 链接器错误:未定义对“EVP cast5”ecb';

Android 链接器错误:未定义对“EVP cast5”ecb';,android,c,android-ndk,openssl,Android,C,Android Ndk,Openssl,我正在尝试使用cast支持编译openssl,但却出现以下错误: SharedLibrary : libcrypto.so ./obj/local/armeabi/objs/crypto/evp/c_allc.o: In function `OpenSSL_add_all_ciphers': ~/testandroid/libssl/jni/crypto/evp/c_allc.c:143: undefined reference to `EVP_cast5_ecb' ~/testandroid

我正在尝试使用cast支持编译openssl,但却出现以下错误:

SharedLibrary  : libcrypto.so
./obj/local/armeabi/objs/crypto/evp/c_allc.o: In function `OpenSSL_add_all_ciphers':
~/testandroid/libssl/jni/crypto/evp/c_allc.c:143: undefined reference to `EVP_cast5_ecb'
~/testandroid/libssl/jni/crypto/evp/c_allc.c:144: undefined reference to `EVP_cast5_cfb64'
~/testandroid/libssl/jni/crypto/evp/c_allc.c:145: undefined reference to `EVP_cast5_ofb'
~/testandroid/libssl/jni/crypto/evp/c_allc.c:146: undefined reference to `EVP_cast5_cbc'
./obj/local/armeabi/objs/crypto/evp/e_old.o: In function `EVP_cast5_cfb':
~/testandroid/libssl/jni/crypto/evp/e_old.c:104: undefined reference to `EVP_cast5_cfb64'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libcrypto.so] Error 1
EVP_cast5_ecb和friends都在~/testandroid/libssl/jni/crypto/EVP/EVP.h和~/testandroid/libssl/jni/include/EVP.h中定义

#ifndef OPENSSL_NO_CAST
const EVP_CIPHER *EVP_cast5_ecb(void);
const EVP_CIPHER *EVP_cast5_cbc(void);
const EVP_CIPHER *EVP_cast5_cfb64(void);
# define EVP_cast5_cfb EVP_cast5_cfb64
const EVP_CIPHER *EVP_cast5_ofb(void);
#endif
在crypto/Android.mk中

local_src_files := \
evp/c_allc.c \
evp/e_old.c \
# And a whole bunch of other c files 

local_c_includes := \
$(APP_PROJECT_PATH) \
$(APP_PROJECT_PATH)/crypto/asn1 \
$(APP_PROJECT_PATH)/crypto/evp \ # evp.h is located here
$(APP_PROJECT_PATH)/include \
$(APP_PROJECT_PATH)/include/openssl # Another evp.h is also located here

include $(CLEAR_VARS)
include $(LOCAL_PATH)/../android-config.mk

ifeq ($(TARGET_ARCH),arm)
    LOCAL_NDK_VERSION := 5
    LOCAL_SDK_VERSION := 9
    # Use the NDK prebuilt libz and libdl.
    LOCAL_LDFLAGS += -lz -ldl
else
    LOCAL_SHARED_LIBRARIES += libz libdl
endif

LOCAL_SRC_FILES += $(local_src_files)
LOCAL_CFLAGS += $(local_c_flags)
LOCAL_C_INCLUDES += $(local_c_includes)
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE:= libcrypto
include $(BUILD_SHARED_LIBRARY)
我可能在这里遗漏了一些非常琐碎的东西,因为我对Android和C一般来说都是新手,所以要友善:)

编辑:我看到有一个用于cast的Makefile。我猜在原始Makefile的最底层有一大堆链接魔法。我如何为Android做一些等效的事情

#
# OpenSSL/crypto/cast/Makefile
#

DIR=    cast
TOP=    ../..
CC=         cc
CPP=    $(CC) -E
INCLUDES=
CFLAG=-g
MAKEFILE=   Makefile
AR=     ar r

CAST_ENC=c_enc.o

CFLAGS= $(INCLUDES) $(CFLAG)
ASFLAGS= $(INCLUDES) $(ASFLAG)
AFLAGS= $(ASFLAGS)

GENERAL=Makefile
TEST=casttest.c
APPS=

LIB=$(TOP)/libcrypto.a
LIBSRC=c_skey.c c_ecb.c c_enc.c c_cfb64.c c_ofb64.c 
LIBOBJ=c_skey.o c_ecb.o $(CAST_ENC) c_cfb64.o c_ofb64.o

SRC= $(LIBSRC)

EXHEADER= cast.h
HEADER= cast_s.h cast_lcl.h $(EXHEADER)

ALL=    $(GENERAL) $(SRC) $(HEADER)

top:
(cd ../..; $(MAKE) DIRS=crypto SDIRS=$(DIR) sub_all)

all:    lib

lib:    $(LIBOBJ)
            $(AR) $(LIB) $(LIBOBJ)
        $(RANLIB) $(LIB) || echo Never mind.
        @touch lib

cast-586.s: asm/cast-586.pl ../perlasm/x86asm.pl ../perlasm/cbc.pl
$(PERL) asm/cast-586.pl $(PERLASM_SCHEME) $(CLAGS) $(PROCESSOR) > $@

files:
$(PERL) $(TOP)/util/files.pl Makefile >> $(TOP)/MINFO

links:
@$(PERL) $(TOP)/util/mklink.pl ../../include/openssl $(EXHEADER)
@$(PERL) $(TOP)/util/mklink.pl ../../test $(TEST)
@$(PERL) $(TOP)/util/mklink.pl ../../apps $(APPS)

install:
@[ -n "$(INSTALLTOP)" ] # should be set by top Makefile...
@headerlist="$(EXHEADER)"; for i in $$headerlist ; \
do  \
(cp $$i $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i; \
chmod 644 $(INSTALL_PREFIX)$(INSTALLTOP)/include/openssl/$$i ); \
done;

tags:
ctags $(SRC)

tests:

lint:
lint -DLINT $(INCLUDES) $(SRC)>fluff

depend:
@[ -n "$(MAKEDEPEND)" ] # should be set by upper Makefile...
$(MAKEDEPEND) -- $(CFLAG) $(INCLUDES) $(DEPFLAG) -- $(PROGS) $(LIBSRC)

dclean:
$(PERL) -pe 'if (/^# DO NOT DELETE THIS LINE/) {print; exit(0);}' $(MAKEFILE) >Makefile.new
mv -f Makefile.new $(MAKEFILE)

clean:
rm -f *.s *.o *.obj lib tags core .pure .nfs* *.old *.bak fluff

# DO NOT DELETE THIS LINE -- make depend depends on it.

c_cfb64.o: ../../e_os.h ../../include/openssl/cast.h
c_cfb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
c_cfb64.o: c_cfb64.c cast_lcl.h
c_ecb.o: ../../e_os.h ../../include/openssl/cast.h
c_ecb.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
c_ecb.o: ../../include/openssl/opensslv.h c_ecb.c cast_lcl.h
c_enc.o: ../../e_os.h ../../include/openssl/cast.h
c_enc.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
c_enc.o: c_enc.c cast_lcl.h
c_ofb64.o: ../../e_os.h ../../include/openssl/cast.h
c_ofb64.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
c_ofb64.o: c_ofb64.c cast_lcl.h
c_skey.o: ../../e_os.h ../../include/openssl/cast.h
c_skey.o: ../../include/openssl/e_os2.h ../../include/openssl/opensslconf.h
c_skey.o: c_skey.c cast_lcl.h cast_s.h

未定义引用…
这样的错误是链接器错误。因此,
evp.h
是否存在并不重要(缺少它会导致编译器失败)。相反,在编译对象之后,链接器找不到包含这些函数的对象。您需要库路径或对象文件,而不是“包含”(用于标题)。也许朝那个方向搜索。嗨,请看我上面的编辑。我想我可能已经找到了一些关于对象文件的东西。我不是这方面的专家,但这里有趣的是
lib
目标,尤其是
$(LIBOBJ)
中的所有变量。在这里,链接似乎发生了。作为起点,您可以尝试这样做:查看实现在哪个对象中(例如
c_enc.o
),然后在编译其他对象时将其交给链接器。您可能需要在此阅读相关理论。如果您还没有这样做,请将
V=1
选项传递到
ndk build
,以便更深入地了解正在发生的事情。