Android NDK, error: undefined reference to function of .h file - android

This is my android.mk file but when I Compile this I get this error
Error while creating
My android.mk file
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libNDK
LOCAL_CFLAGS := -DANDROID_NDK \
-DDISABLE_IMPORTGL
LOCAL_SRC_FILES := SerialPort.c
LOCAL_CFLAGS := -std=c99
LOCAL_LDLIBS := -lGLESv1_CM -ldl -llog
include $(BUILD_SHARED_LIBRARY)

Related

I am getting error while ndk build in android.mk file

I am getting error during ndk build. I have only one android.mk file and only one Application.mk file in my project
Android NDK: Trying to define local module 'protobuf' in /home/parag.j/AndroidArm//jni/Android.mk.
Android NDK: But this module was already defined by /home/parag.j/AndroidArm//jni/Android.mk.
Here is my Android.mk file
LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE=ndktest
LOCAL_SRC_FILES=ndktest.cpp
include $(CLEAR_VARS)
LOCAL_MODULE := c++_shared
LOCAL_SRC_FILES := $(LOCAL_PATH)/inc/build/libc++_shared.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := armnn
LOCAL_SRC_FILES := $(LOCAL_PATH)/inc/build/libarmnn.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := armnnTfParser
LOCAL_SRC_FILES := $(LOCAL_PATH)/inc/build/libarmnnTfParser.so
include $(PREBUILT_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := protobuf
LOCAL_SRC_FILES := $(LOCAL_PATH)/inc/build/libprotobuf.so
include $(PREBUILT_SHARED_LIBRARY)
LOCAL_LDLIBS += -lm -llog -landroid
LOCAL_CFLAGS += -DARM_NEON_64BIT -O3 -mfpu=neon -mcpu=kryo -std=c++14 -pie
LOCAL_SHARED_LIBRARIES := opencv_java3 armnn armnnTfParser protobuf c++_shared
LOCAL_C_INCLUDES := $(LOCAL_PATH)/inc/include\
include $(BUILD_SHARED_LIBRARY)
Here is my Application.mk file
APP_ABI:=arm64-v8a
APP_CFLAGS += -Ofast
APP_OPTIM := release
APP_STL := gnustl_static
APP_CPPFLAGS := -frtti -fexceptions
APP_PLATFORM := android-22
ANDROID_TOOLCHAIN_NAME := clang++
You forgot to (re)set LOCAL_MODULE for the last part of your makefile. I think the last few lines should be:
LOCAL_MODULE=ndktest
LOCAL_SRC_FILES=ndktest.cpp
LOCAL_LDLIBS += -lm -llog -landroid
LOCAL_CFLAGS += -DARM_NEON_64BIT -O3 -mfpu=neon -mcpu=kryo -std=c++14 -pie
LOCAL_SHARED_LIBRARIES := opencv_java3 armnn armnnTfParser protobuf c++_shared
LOCAL_C_INCLUDES := $(LOCAL_PATH)/inc/include
include $(BUILD_SHARED_LIBRARY)
(and get rid of the ndktest lines at the start of the file, of course)

How to fix the NDK build error: pread failed: Is a directory?

I got the following error when i build some native codes on android:
/Users/jerikc/Library/Android/android-ndk-r10d/toolchains/arm-linux-androideabi-4.8/prebuilt/darwin-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.8/../../../../arm-linux-androideabi/bin/ld: fatal error: /Users/jerikc/workdir/workspace/projuect: pread failed: Is a directory
collect2: error: ld returned 1 exit status
The ndk version is: r10d
The Android.mk :
LOCAL_MODULE := libpng
LOCAL_SRC_FILES += \
../jniLibs/$(TARGET_ARCH_ABI)/libpng.a
LOCAL_EXPORT_C_INCLUDES += \
libpng
include $(PREBUILT_STATIC_LIBRARY)
LOCAL_MODULE := libjpeg
LOCAL_SRC_FILES += \
../jniLibs/$(TARGET_ARCH_ABI)/libjpeg.a
LOCAL_EXPORT_C_INCLUDES += \
libjpeg
include $(PREBUILT_STATIC_LIBRARY)
LOCAL_MODULE := libcrypto
LOCAL_SRC_FILES += \
../jniLibs/$(TARGET_ARCH_ABI)/libcrypto.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := processing
LOCAL_SRC_FILES += filter_jni.c \
control.c
LOCAL_CFLAGS := -g -O3 -ffast-math
LOCAL_LDLIBS := -llog -lm -lz
LOCAL_STATIC_LIBRARIES += libpng libjpeg libcrypto
include $(BUILD_SHARED_LIBRARY)
You have to use $(CLEAR_VARS) to clean up your local variables, on which make is working now.
Here is the link, where you can find some useful info about it: http://android.mk/
I assume, that following version will solve your problem. I don't have system to check it right now.
include $(CLEAR_VARS)
LOCAL_MODULE := libpng
LOCAL_SRC_FILES += \
../jniLibs/$(TARGET_ARCH_ABI)/libpng.a
LOCAL_EXPORT_C_INCLUDES += \
libpng
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libjpeg
LOCAL_SRC_FILES += \
../jniLibs/$(TARGET_ARCH_ABI)/libjpeg.a
LOCAL_EXPORT_C_INCLUDES += \
libjpeg
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := libcrypto
LOCAL_SRC_FILES += \
../jniLibs/$(TARGET_ARCH_ABI)/libcrypto.a
include $(PREBUILT_STATIC_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := processing
LOCAL_SRC_FILES += filter_jni.c \
control.c
LOCAL_CFLAGS := -g -O3 -ffast-math
LOCAL_LDLIBS := -llog -lm -lz
LOCAL_STATIC_LIBRARIES += libpng libjpeg libcrypto
include $(BUILD_SHARED_LIBRARY)

undefined reference error while building FFMPEG with NDK

I get this error while running build-ndk for my ffmpeg android project
make: *** [obj/local/armeabi-v7a/libffmpeg-test-jni.so]
undefined reference to 'av_close_input_file'
undefined reference to 'av_find_stream_info'
undefined reference to 'av_open_input_file'
undefined reference to 'avcodec_open'
Any solutions to get rid of this error ? I am very new to ffmpeg and Android NDK
This is my Android MK file
LOCAL_PATH := $(call my-dir)
#declare the prebuilt library
include $(CLEAR_VARS)
LOCAL_MODULE := ffmpeg-prebuilt
LOCAL_SRC_FILES := ffmpeg-2.5.4/android/armv7-a/libffmpeg.so
LOCAL_EXPORT_C_INCLUDES := ffmpeg-2.5.4/android/armv7-a/include
LOCAL_EXPORT_LDLIBS := ffmpeg-2.5.4/android/armv7-a/libffmpeg.so
LOCAL_LDLIBS += -llog -lavutil -lavformat -lavcodec -lz -lavutil -lm
LOCAL_PRELINK_MODULE := true
include $(PREBUILT_SHARED_LIBRARY)
#the andzop library
include $(CLEAR_VARS)
LOCAL_ALLOW_UNDEFINED_SYMBOLS=false
LOCAL_MODULE := ffmpeg-test-jni
LOCAL_SRC_FILES := ffmpeg-test-jni.c
LOCAL_C_INCLUDES := $(LOCAL_PATH)/ffmpeg-2.5.4/android/armv7-a/include
LOCAL_SHARED_LIBRARY := ffmpeg-prebuilt
LOCAL_LDLIBS := -llog -ljnigraphics -lz -lm $(LOCAL_PATH)/ffmpeg-2.5.4/android/armv7-a/libffmpeg.so
include $(BUILD_SHARED_LIBRARY)
Any Pointers much appreciated
Thanks!

Android studio NDK Undefined reference to GL functions

I made small JNI-based project.
I do #include GLES3/gl3.h in my C code and it works. But when I try to use ANY OpenGL function it says Undefined reference to gl*. My Android.mk is:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := hello-jni
LOCAL_CFLAGS := -Wall -Wextra
LOCAL_SRC_FILES := hello-jni.c
LOCAL_LDLIBS := -lGLESv3 -ldl -llog
LOCAL_STATIC_LIBRARIES := android_native_app_glue
include $(BUILD_SHARED_LIBRARY)
What I am doing wrong? Could some one tell me what's wrong?
Try linking to EGL as well.
For my projects, I use these libraries:
LOCAL_LDLIBS := -llog -landroid -lEGL -lGLESv3

how to generate two .so file in a single android.mk file

I'd like to create two .so file within a single .mk file. But the following codes fails because there should not be a space in LOCAL_MODULE. So is there a way out?
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := gpio hello-jni
LOCAL_CFLAGS := -Werror
LOCAL_SRC_FILES := gpio.c hello-jni.c
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
I just got it works using the following codes.
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := gpio
LOCAL_CFLAGS := -Werror
LOCAL_SRC_FILES := gpio.c
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)
include $(CLEAR_VARS)
LOCAL_MODULE := h ello-jni
LOCAL_CFLAGS := -Werror
LOCAL_SRC_FILES := hello-jni.c
LOCAL_LDLIBS := -llog
include $(BUILD_SHARED_LIBRARY)

Categories

Resources