Android.mk variable to link system or external library during compilation

LOCAL_LDLIBS

This variable contains the list of additional linker flags for use in building your shared library or executable. It enables you to use the -l prefix to pass the name of specific system libraries. For example, the following example tells the linker to generate a module that links to /system/lib/libz.so at load time:

LOCAL_LDLIBS := -lz

Using this, LOCAL_LDLIBS variable you can also specify the path to the library, for example, your library libmylibrary.so resides in path /home/myuser/android/mylibrary/lib/libmylibrary.so, the you can use below code to link this library,

LOCAL_LDLIBS := -L/home/myuser/android/mylibrary/lib/

Related :   How to capture Bluetooth packets on Android ?

Example Android.mk might look like below,

$ vim Android.mk
include $(CLEAR_VARS)
LOCAL_LDLIBS += -llog -lz
LOCAL_STATIC_LIBRARIES := libavformat libavcodec libpostproc libswscale libavutil libx264 libswresample
LOCAL_C_INCLUDES += $(LOCAL_PATH)/ffmpeg
LOCAL_SRC_FILES := FFNewChunkedAudioVideoEncoder.c
LOCAL_CFLAGS := -march=armv7-a -mfloat-abi=softfp -mfpu=neon
LOCAL_MODULE := FFNewChunkedAudioVideoEncoder
include $(BUILD_SHARED_LIBRARY)

Reference – https://github.com/OpenWatch/ClientExperiments-Android/blob/master/jni/Android.mk

Reference : http://developer.android.com/ndk/guides/android_mk.html


lynxbee_ezoic

Subscribe with Valid Email Id to receive updates in Inbox. ( Secured by Google FeedBurner )

   


Leave a Comment

Android Android Applications Android Build system Android Commands Application Libraries Application Stack / User Interface Bash / Shell Scripts Bluetooth driver Cloud Technologies Commands and Packages Compilation Content Management System Core Kernel C Programs Development & Build Development, Debugging and Performance Tools Development Environment Setup Django & REST Api Errors & Failures Git Hardware Platforms HTML JAVA Programs Linux, OS Concepts and Networking Linux Device Drivers Linux Host, Ubuntu, SysAdmin Linux Kernel Linux Networking Middleware Libraries, HAL Multimedia Audio, Video, Images NDK / Middleware / HAL OS Concepts PHP Programming Languages Scripting and Automation Search Engine Optimisation ( SEO ) Social Media Source Code Management ( SCM ) System Administration, Security Testing and Debugging Uncategorized Web design and development Website Hosting Wordpress Yocto / Bitbake / Openembedded