- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我从来没有用 Android 构建过 curl。
先决条件:我正在使用 Android Studio 2.1.2我正在使用 NDK ,非实验性方式我在 curlLib 目录的 jni 文件夹中有 curl-7.49.1 库的源代码ExtLibCurl 是我的应用程序 jni 文件夹中的文件夹/目录,其中包含从下载的源代码 https://android.googlesource.com/platform/external/curl/+/e6f2b03027b5feb92b30f5d47801ec3fabe9fd95
可以检查 Android.mk 中的 cURL 和其他文件。
根据问题中的评论更新文件。
以下是我的Android.mk文件
JNI_DIR := $(call my-dir)
LOCAL_PATH:= $(JNI_DIR)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/ExtLibCurl/Android.mk
# Build main library as shared library.
LOCAL_PATH := $(JNI_DIR)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES := $(LOCAL_PATH)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ExtLibCurl/include/curl
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ExtLibCurl/lib
FILE_LIST += $(wildcard $(LOCAL_PATH)/ExtLibCurl/src/*.c)
LOCAL_MODULE := ndksampleapp
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_STATIC_LIBRARIES := ExtLibCurl
include $(BUILD_SHARED_LIBRARY)
应用程序.mk
APP_ABI := all
APP_STL := gnustl_static
APP_CFLAGS += -std=gnu++11
APP_OPTIM := debug
LOCAL_CPP_FEATURES += exceptions
NDK_TOOLCHAIN_VERSION := 4.9
我构建 curl 的 Android.mk 的方式是否正确?
当我在 src\main 路径中执行 ndk-build 时,出现以下错误
[arm64-v8a] Compile : ndksampleapp <= curlutil.c
cc1.exe: warning: command line option '-std=gnu++11' is valid for C++/ObjC++ but not for C
In file included from jni/ExtLibCurl/lib/strdup.h:24:0,
from jni/ExtLibCurl/src/setup.h:206,
from jni/ExtLibCurl/src/curlutil.c:23:
jni/ExtLibCurl/lib/setup.h:120:28: fatal error: curl/curlbuild.h: No such file or directory
#include <curl/curlbuild.h>
^
compilation terminated.
make: *** [obj/local/arm64-v8a/objs-debug/ndksampleapp/ExtLibCurl/src/curlutil.o] Error 1
如果我删除 FILE_LIST += $(wildcard $(LOCAL_PATH)/ExtLibCurl/src/*.c),则不会构建任何 cURL 文件。
最佳答案
您的 Android.mk
文件应如下所示:
JNI_DIR := $(call my-dir)
LOCAL_PATH:= $(JNI_DIR)
include $(CLEAR_VARS)
include $(LOCAL_PATH)/ExtLibCurl/Android.mk
# Build main library as shared library.
LOCAL_PATH := $(JNI_DIR)
include $(CLEAR_VARS)
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ExtLibCurl/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ExtLibCurl/lib
# !!! place list of YOUR sources to this variable !!!
FILE_LIST += $(wildcard $(LOCAL_PATH)/src/*.c)
LOCAL_MODULE := ndksampleapp
LOCAL_SRC_FILES := $(FILE_LIST:$(LOCAL_PATH)/%=%)
LOCAL_STATIC_LIBRARIES := libcurl
LOCAL_LDLIBS += -lz
include $(BUILD_SHARED_LIBRARY)
模块的名称不需要与其目录名称匹配。
在 ExtLibCurl/Android.mk
中,您必须取消注释 BUILD_STATIC_LIBRARY
部分,您还可以通过创建可执行文件 curl(第 74 行以上)删除所有部分,即文件将如下所示:
# Google Android makefile for curl and libcurl
#
# Place the curl source (including this makefile) into external/curl/ in the
# Android source tree. Then build them with 'make curl' or just 'make libcurl'
# from the Android root. Tested with Android 1.5
#
# Note: you must first create a curl_config.h file by running configure in the
# Android environment. The only way I've found to do this is tricky. Perform a
# normal Android build with libcurl in the source tree, providing the target
# "showcommands" to make. The build will eventually fail (because curl_config.h
# doesn't exist yet), but the compiler commands used to build curl will be
# shown. Now, from the external/curl/ directory, run curl's normal configure
# command with flags that match what Android itself uses. This will mean
# putting the compiler directory into the PATH, putting the -I, -isystem and
# -D options into CPPFLAGS, putting the -m, -f, -O and -nostdlib options into
# CFLAGS, and putting the -Wl, -L and -l options into LIBS, along with the path
# to the files libgcc.a, crtbegin_dynamic.o, and ccrtend_android.o. Remember
# that the paths must be absolute since you will not be running configure from
# the same directory as the Android make. The normal cross-compiler options
# must also be set.
#
# The end result will be a configure command that looks something like this
# (the environment variable A is set to the Android root path):
#
# A=`realpath ../..` && \
# PATH="$A/prebuilt/linux-x86/toolchain/arm-eabi-X/bin:$PATH" \
# ./configure --host=arm-linux CC=arm-eabi-gcc \
# CPPFLAGS="-I $A/system/core/include ..." \
# CFLAGS="-fno-exceptions -Wno-multichar ..." \
# LIB="$A/prebuilt/linux-x86/toolchain/arm-eabi-X/lib/gcc/arm-eabi/X\
# /interwork/libgcc.a ..." \
#
# Dan Fandrich
# September 2009
LOCAL_PATH:= $(call my-dir)
common_CFLAGS := -Wpointer-arith -Wwrite-strings -Wunused -Winline -Wnested-externs -Wmissing-declarations -Wmissing-prototypes -Wno-long-long -Wfloat-equal -Wno-multichar -Wsign-compare -Wno-format-nonliteral -Wendif-labels -Wstrict-prototypes -Wdeclaration-after-statement -Wno-system-headers -DHAVE_CONFIG_H
#########################
# Build the libcurl library
include $(CLEAR_VARS)
include $(LOCAL_PATH)/lib/Makefile.inc
CURL_HEADERS := \
curlbuild.h \
curl.h \
curlrules.h \
curlver.h \
easy.h \
mprintf.h \
multi.h \
stdcheaders.h \
typecheck-gcc.h \
types.h
LOCAL_SRC_FILES := $(addprefix lib/,$(CSOURCES))
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/include \
external/openssl/include \
external/zlib
LOCAL_CFLAGS += $(common_CFLAGS)
LOCAL_COPY_HEADERS_TO := libcurl/curl
LOCAL_COPY_HEADERS := $(addprefix include/curl/,$(CURL_HEADERS))
#LOCAL_SHARED_LIBRARIES := libz
LOCAL_MODULE:= libcurl
include $(BUILD_STATIC_LIBRARY)
关于android - jni/Android.mk :8:curlLib/packages/Android/Android. mk: 没有那个文件或目录,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/39202545/
我对Android.mk & Application.mk的使用有点模糊 我已尝试阅读 documentation that comes with NDK 中的 APPLICATION-MK.HTML
我需要在 Application.mk 文件中指定库的路径才能正确链接它。这个怎么做?有任何 GCC 命令吗? 最佳答案 您必须将 LOCAL_LDLIBS := -L/path/to/the/lib
在 The Little Schemer book ,在第 9 章中,在为任意长输入构建 length 函数时,建议执行以下操作(在 pages 170-171 上),即以下代码片段(来自 page
我使用 jni 创建了一个 Android 项目。现在我想使用预处理器宏来区分精简版和完整版。它应该看起来像这样: #ifdef LITE auto label = LabelTTF::cre
看起来有可能,但我的脚本产生了奇怪的结果: LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) include $(LOCAL_PATH)/libos/
我正在深入研究在我的项目中使用android tesseract api。 https://github.com/rmtheis/tess-two 我将 com_googlecode_leptonic
在 Android 应用程序中,我想将一个 android.mk 文件导入应用程序中的另一个 Android.mk 文件 为此,我在一个 Andorid.mk 文件中使用了该文件,该文件将被导入到同一
这是代码 -(id) initWithNibName:(NSString*) nibNameOrNil bundle:(NSBundle*)nibBundleOrNil { ... [se
我已经下载了 OpenCV for Android 版本 3.2 并将其 java 模块导入到我的项目中。我已将 native (c++) 代码复制到 openCVLibrary320/app/src
我从来没有用 Android 构建过 curl。 先决条件:我正在使用 Android Studio 2.1.2我正在使用 NDK ,非实验性方式我在 curlLib 目录的 jni 文件夹中有 cu
我有一个顶级 defines.mk 文件,它列出了某些目录和 C 库,根据项目的不同而包含。 KERNEL_LIB = -lkdev DRIVER_LIB = -ldriver -lutil -li
Android.mk简介: Android.mk文件用来告知NDK Build 系统关于Source的信息。 Android.mk将是GNU Makefile的一部分,且将被Build
我觉得 CMake 和 Android.mk 有很多共同点,有人可以向我解释一下有什么区别,为什么谷歌发明了一个新的构建系统而不使用 CMake? 最佳答案 Android 开发人员有更多的变化。现在
我正在努力获取一个模块以在 Android 上编译。它引用了一个已经存在的共享库——我只有 .so 和 .h 文件。 我当前的 Android.mk 如下所示: LOCAL_PATH:= $(call
嗨,我是 android 应用程序的新手,你能告诉我如何创建 jni 和 android.mk ....我知道 jni 的目的但是如何在我的项目中创建那个 jni 告诉我一步一步 最佳答案 嗨NDK
在Android.mk中有什么方法可以使用条件表达式吗?我需要它来做这样的事: IF arch = AREABI_V7 *use path for my arm_v7 static libs*
在我的新项目中,我需要基于一个c写的项目。而且我知道我可以使用 NDK 来完成它,但这里有一个问题:如何将标准的 Makefile 重写到 Android.mk 中?再者,在Android中,是否可以
我正在使用 Android NDK 构建我的 cocos2dx 项目,在 Android.mk 中,有一个 LOCAL_SRC_FILES 的定义,其中列出了每个 cpp 文件。每当我添加一个新的源文
我正在尝试使用 android ndk(在 Windows 上)构建一个项目,但我遇到了一些问题,特别是源文件(Android.mk 中的 LOCAL_SRC_FILES) 我正在尝试使用父文件夹的相
LOCAL_PATH := $(call my-dir) TOP_LOCAL_PATH := $(call my-dir)/../ #Add target arm version ifeq ($(TA
我是一名优秀的程序员,十分优秀!