ndk build_static_library make: Nothing to be done for `all' - android

I meet a problem when I build the libjpeg on android in eclipse. The jni contains Android.mk as follow:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_SRC_FILES := hello-jni.c
#LOCAL_C_INCLUDES := $(LOCAL_PATH)/jpeg8d-master
#LOCAL_STATIC_LIBRARIES := libjpeg
include $(BUILD_STATIC_LIBRARY)
#include $(LOCAL_PATH)/jpeg8d-master/Android.mk
The jpeg8d is the source code I download from github. The android.mk
LOCAL_PATH:= $(call my-dir)
# ------------------------------------------------------------------
# Static library for Cocos
# ------------------------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := cocos_jpeg_static
LOCAL_MODULE_FILENAME := libjpeg
LOCAL_SRC_FILES := \
jcapimin.c jcapistd.c jccoefct.c jccolor.c jcdctmgr.c jchuff.c \
jcinit.c jcmainct.c jcmarker.c jcmaster.c jcomapi.c jcparam.c \
jcprepct.c jcsample.c jctrans.c jdapimin.c jdapistd.c \
jdatadst.c jdatasrc.c jdcoefct.c jdcolor.c jddctmgr.c jdhuff.c \
jdinput.c jdmainct.c jdmarker.c jdmaster.c jdmerge.c \
jdpostct.c jdsample.c jdtrans.c jerror.c jfdctflt.c jfdctfst.c \
jfdctint.c jidctflt.c jidctfst.c jidctint.c jquant1.c \
jquant2.c jutils.c jmemmgr.c jcarith.c jdarith.c jaricom.c
# Use the no backing store memory manager provided by
# libjpeg. See install.txt
LOCAL_SRC_FILES += \
jmemnobs.c
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(BUILD_STATIC_LIBRARY)
ndk-build give the tips :
make: Nothing to be done for `all'.
But if I Set the jpeg8d Android.mk BUILD_SHARED_LIBRARY,I get the libjpeg.so.
I don't know why. Can anyone help me ?

Solution:
You can redefine the library name by the LOCAL_MODULE_FILENAME. In my problem, I have set the LOCAL_MODULE_FILENAME=libjpeg, but I don't add the
APP_MODULES:=cocos_jpeg_static (remember cocos_jpeg_staic is the LOCAL_MODULE not the LOCAL_MODULE_FILENAME) into the Application.mk which is in the jni directory not in the jpeg8d-master directory.
I generate the libjpeg.a when i add this line into the Appliction.mk
APP_MODULES:=cocos_jpeg_static

Related

While building the AOSP build tree, LOCAL_MODULE not defined error is occures

While building the AOSP (Oreo)source tree, The following error occurs
build/core/dynamic_binary.mk:17: error: packages/apps/TerminalTest/jni:
LOCAL_MODULE not defined before call to local-intermediates-dir.
18:25:16 ckati failed with: exit status 1
#### failed to build some targets (26 seconds) ####
Application Source tree
jni
Android.mk
src
res
Android.mk
Main Android.mk
LOCAL_PATH:= $(call my-dir)
include $(call all-subdir-makefiles)
include $(CLEAR_VARS)
LOCAL_PACKAGE_NAME := TerminalTest
LOCAL_MODULE_TAGS := optional
LOCAL_MODULE := libjni_terminal
LOCAL_SRC_FILES := $(call all-subdir-java-files)
LOCAL_STATIC_JAVA_LIBRARIES := android-support-v4
LOCAL_JNI_SHARED_LIBRARIES := libjni_terminalTest
# TODO: enable proguard once development has settled down
#LOCAL_PROGUARD_FLAG_FILES := proguard.flags
LOCAL_PROGUARD_ENABLED := disabled
include $(BUILD_PACKAGE)
jni/Android.mk
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := \
jni_init.cpp \
com_android_terminal_Terminal.cpp \
LOCAL_C_INCLUDES += \
external/libvterm/include \
libcore/include \
frameworks/base/include
LOCAL_SHARED_LIBRARIES := \
libandroidfw \
libandroid_runtime \
liblog \
libnativehelper \
libutils
LOCAL_STATIC_LIBRARIES := \
libvterm
LOCAL_CFLAGS := \
-Wno-unused-parameter \
LOCAL_MODULE := libjni_terminal
LOCAL_MODULE_TAGS := optional
include $(BUILD_SHARED_LIBRARY)
Any help will appreciate
If you use LOCAL_MODULE := libjni_terminal in any other project this error will happen.
When using the same LOCAL_MODULE name in different places lead to problems while creating and accessing intermediate files.

Compiling native android library with multiple c files using ndk build errors * No rule to make target

I am having an issue compiling a shared C library into a .so for android. I've copied all the .c and .h files into the jni folder. I posted a screenshot below to show the contents of the Android.mk file as well as the folder hierarchy.
below is the output of ndk-build run in the project root folder NTRUMLS
[kenway#jackdaw NTRUMLS]$ ndk-build
make: *** No rule to make target '/media/bigdata/Android/Sdk/ndk-bundle/build/core/crypto_hash_sha512.c', needed by 'obj/local/arm64-v8a/objs/ntrumls/crypto_hash_sha512.o'. Stop.
i checked for spaces and typo's. here's the contents of my Android.mk copied directly below.
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_PATH := $(call my-dir)
LOCAL_MODULE := libntrumls
LOCAL_CFLAGS := -Werror
LOCAL_SRC_FILES := crypto_hash_sha512.c \
crypto_stream.c \
convert.c \
randombytes.c \
fastrandombytes.c \
pack.c \
pol.c \
params.c \
pqntrusign.c \
shred.c
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
Move
LOCAL_PATH := $(call my-dir)
to be the first statement of your Android.mk script.
Try following
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_ARM_MODE := arm
LOCAL_MODULE := libntrumls
LOCAL_CFLAGS := -Werror
LOCAL_SRC_FILES := Main_M1_play.cpp
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)

Cocos2d-x 3.X build Android "cocos2d.h" file not found

I am using build_native.py to build to Android platform, but it says
"fatal error: fatal error:'cocos2d.h' file not found".
Before this problem it says can't import import module and I set NDK_MODULD_PATH in environment variable to fix it I don't know if this cause this problem.
In file included from jni/hellocpp/main.cppIn file included from
jni/../../Class
es/AppDelegate.cppIn file included from jni/../../Classes/GameOverScene.cpp:1:
::jni/../../Classes/GameOverScene.h1:
:4:10: jni/../../Classes/AppDelegate.hfatal error: :4'cocos2d.h' file not found1
:
In file included from #include "cocos2d.h"
this is my Android.mk
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/external)
$(call import-add-path,$(LOCAL_PATH)/../../cocos2d/cocos)
LOCAL_MODULE := cocos2dcpp_shared
LOCAL_MODULE_FILENAME := libcocos2dcpp
LOCAL_SRC_FILES := hellocpp/main.cpp \
../../Classes/AppDelegate.cpp \
../../Classes/Adapter.cpp \
../../Classes/ControlLayer.cpp \
../../Classes/GameOverScene.cpp \
../../Classes/GameRunScene.cpp \
../../Classes/GameStartScene.cpp \
../../Classes/SceneManager.cpp \
../../Classes/HelloWorldScene.cpp
LOCAL_C_INCLUDES := $(LOCAL_PATH)/../../cocos2d/cocos/physics
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../Classes
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../../libcocos2d
LOCAL_STATIC_LIBRARIES := cocos2dx_static
LOCAL_STATIC_LIBRARIES := cocos2dx_extension_static
LOCAL_LDLIBS += -L$(call host-path,$(NDK_ROOT)/sources/cxx-stl/llvm-libc++/libs/$(TARGET_ARCH_ABI)) -lc++_static
include $(BUILD_SHARED_LIBRARY)
$(call import-module,./prebuilt-mk)
In this situation, most error comes from wrong Path setting of NDK_MODULD_PATH. I once met this error when using Cocos2d-x 2.2.6. And I suggest you checking the path of NDK_MODULE_PATH again to set it to
${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/source;${COCOS2DX_ROOT}/cocos2dx/platform/third_party/android/prebuilt
replace ${COCOS2DX_ROOT} to your own path. You can also check this article, although it is talking about Cocos2d-x 2.x.
I miss this error also when I use cocos2d-x-3.7.My solution is at jni/Android.mk set:
LOCAL_STATIC_LIBRARIES := cocos2d_lua_static
see more at this FixBug

How to add static c-library (libsrtp) to Android-Project using NDK

so I'm relatively new to Android-NDK and trying to add an uncompiled c-library to android.
I've downloaded the library's source from here and followed these instructions to create a static library (.a-File) from the downloaded files using ndk-build.
So now I have a folder-structure that looks like this:
-srtp
--include (srtp.h, crypto.h)
--srtp (srtp.c...)
--obj
---local
----armeabi
-----libsrtp_static.a
In my Android-project I want to include srtp.h in a c-file inside my /jni/ folder. I've tried to just add the .a-file to the /jni folder but than it says "srtp.h no such file or direcotry". If I add the entire srtp-folder to the project and include the header with "srtp/include/srtp.h" it compiles but fails to link the source as I get the error "Undefined reference to srtp-function-call"
Here's my Android.mk (parts of it copied from Android.mk within the downloaded source):
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_MODULE := ndk1 #name of my project
LOCAL_SRC_FILES := native.c #name of the c-source file
include $(BUILD_SHARED_LIBRARY)
LOCAL_PATH:= /home/dev/programing/srtp
common_SRC_FILES := \
srtp/srtp.c \
srtp/ekt.c \
crypto/cipher/cipher.c \
#...more files like that
common_CFLAGS := \
-DPOSIX -iquote$(LOCAL_PATH)/crypto/include \
-Werror \
-Wno-ignored-qualifiers \
-Wno-sign-compare \
-Wno-missing-field-initializers
common_C_INCLUDES = $(LOCAL_PATH)/include
# For the device
# =====================================================
# Device static library
include $(CLEAR_VARS)
ifneq ($(TARGET_ARCH),x86)
LOCAL_NDK_VERSION := 5
LOCAL_SDK_VERSION := 9
endif
LOCAL_SRC_FILES := libsrtp_static.a
LOCAL_CFLAGS += $(common_CFLAGS)
LOCAL_C_INCLUDES += /home/dev/programing/srtp/include
LOCAL_MODULE:= libsrtp_static
LOCAL_MODULE_TAGS := optional
include $(BUILD_STATIC_LIBRARY)
Any help is greatly appreciated! Thank you very much.
You need to add the reference to libsrtp_static from your lib (ndk1) declaration :
LOCAL_STATIC_LIBRARIES := libsrtp_static
Also, you don't need to copy all the strp sources to your project, only add this to your static prebuilt library definition
LOCAL_EXPORT_C_INCLUDES += /home/dev/programing/srtp/include
This path will then be automatically added to the LOCAL_C_INCLUDES of your library that is using the library.
Are you building libsrtp or just using a prebuilt static library ? If you're using a prebuilt (lib*.a), replace BUILD_STATIC_LIBRARY with PREBUILT_STATIC_LIBRARY and set only the .a as SRC_FILE:
In summary, once libstrp_static.a is built, this should work:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_LDLIBS := -llog
LOCAL_MODULE := ndk1 #name of my project
LOCAL_SRC_FILES := native.c #name of the c-source file
LOCAL_STATIC_LIBRARIES := libsrtp_static
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_SRC_FILES := /home/dev/programing/srtp/libsrtp_static.a #check path to libsrtp_static.a
LOCAL_EXPORT_C_INCLUDES += /home/dev/programing/srtp/include
LOCAL_MODULE:= libsrtp_static
LOCAL_MODULE_TAGS := optional
include $(BUILD_STATIC_LIBRARY)

Android NDK: Including boost c++ library

I am trying to use a boost library inside my android application, using the NDK. I have found a couple of success stories here and here, but I can't say the same about me. I am specifically trying to use the library in this link, as well as the boost thread library. In the code below, I am only trying to include the thread library, not the math library. The process I used to build the boost libraries is pretty much the same as the first link I attached.
So far, it seems I have successfully built the boost libraries, but when I run ndk-build, I get the following error:
Prebuilt : libboost_thread.a <= <NDK>/sources/
cp: omitting directory `path/to/ndk/sources/boost'
make: *** [obj/local/armeabi/libboost_thread.a] Error 1
Obviously the cp: omitting directory... is not exactly an error. But the only thing I'm getting other than that is the next line, which doesn't really mean anything. Error 1
Here's my Android.mk file:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_STATIC_LIBRARIES := boost_thread
LOCAL_LDLIBS := lboost_system-gcc-md lboost_thread-gcc-md -lgnustl_static
LOCAL_LDLIBS += lboost_system-gcc-md lboost_thread-gcc-md \
-L$(NDK_ROOT)/sources/cxx-stl/gnu-libstdc++/libs/armeabi \
-lgnustl_static
LOCAL_SRC_FILES := #cpp_sources
LOCAL_MODULE := com_example_ndkFile_CppMethods
include $(BUILD_SHARED_LIBRARY)
$(call import-module,boost)
And there's also an Android.mk file in path/to/ndk/sources/boost/:
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE:= boost_thread
LOCAL_SRC_FILES:= android/lib/libboost_thread.a
LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
include $(PREBUILT_STATIC_LIBRARY)
And my humble Application.mk file:
APP_ABI := armeabi armeabi-v7a
APP_STL := gnustl_static
APP_CPPFLAGS = -fexceptions
I built the boost libraries using bjam. All of the libboost_###.a files are in the sources/boost/android/lib folder.
What is the error I'm getting?
I built the boost libraries using Boost-for-Android. Then I have in my boost/include/lib directory the android makefile boost.mk
LOCAL_PATH := $(call my-dir)
# boost_date_time
#
include $(CLEAR_VARS)
LOCAL_MODULE := boost_date_time
LOCAL_SRC_FILES := libboost_date_time-gcc-mt-1_53.a
include $(PREBUILT_STATIC_LIBRARY)
# boost_filesystem
#
include $(CLEAR_VARS)
LOCAL_MODULE := boost_filesystem
LOCAL_SRC_FILES := libboost_filesystem-gcc-mt-1_53.a
include $(PREBUILT_STATIC_LIBRARY)
# boost_thread
#
include $(CLEAR_VARS)
LOCAL_MODULE := boost_thread
LOCAL_SRC_FILES := libboost_thread-gcc-mt-1_53.a
include $(PREBUILT_STATIC_LIBRARY)
# boost_system
#
include $(CLEAR_VARS)
LOCAL_MODULE := boost_system
LOCAL_SRC_FILES := libboost_system-gcc-mt-1_53.a
include $(PREBUILT_STATIC_LIBRARY)
# boost_program_options
#
include $(CLEAR_VARS)
LOCAL_MODULE := boost_program_options
LOCAL_SRC_FILES := libboost_program_options-gcc-mt-1_53.a
include $(PREBUILT_STATIC_LIBRARY)
# boost_chrono
#
include $(CLEAR_VARS)
LOCAL_MODULE := boost_chrono
LOCAL_SRC_FILES := libboost_chrono-gcc-mt-1_53.a
include $(PREBUILT_STATIC_LIBRARY)
and my module where i use some of the boost libraries looks like this
LOCAL_PATH := $(call my-dir)
# SignalServer, executable
#
include $(CLEAR_VARS)
LOCAL_CFLAGS := -DTIXML_USE_TICPP
#LOCAL_CFLAGS += -DDEBUG
LOCAL_STATIC_LIBRARIES := boost_thread \
boost_system \
boost_filesystem \
boost_program_options \
boost_chrono \
LOCAL_STATIC_LIBRARIES += ticpp \
tia \
tobicore \
tobiid \
tid \
gdf
LOCAL_MODULE := signalserver
LOCAL_C_INCLUDES := $(LOCAL_PATH)/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/extern/include
LOCAL_C_INCLUDES += $(LOCAL_PATH)/../boost/include/boost-1_53
LOCAL_SRC_FILES := #cpp source
include $(BUILD_EXECUTABLE)
in addition I have an Android.mk where all subdir makefiles are listed
TOP_PATH := $(call my-dir)
include $(TOP_PATH)/boost/lib/boost.mk
include $(TOP_PATH)/signalserver/signalserver.mk
.
.
and my Application.mk:
APP_PLATFORM := android-14
APP_ABI := armeabi-v7a
#APP_OPTIM := debug
#NDK_DEBUG := 1
NDK_TOOLCHAIN_VERSION := 4.6
APP_STL := gnustl_static
APP_CPPFLAGS := -fexceptions -frtti
Here: http://silverglint.com/boost-for-android/ you can find a simple script that lets you build a modern version of boost for android, or simply download prebuilt boost binaries.
Also included is a sample test app that shows you how to include/link the boost headers/binaries

Categories

Resources