Andrew
Andrew

Reputation: 161

Include C++ shared library in self-built android. Error while launch ndk-build

I trying to include simple C++ shared library in self-built android distribution. It has been compiled with g++ without any errors and warnings.

For right now I need to include this .so library into self-built android.

I copied my source into '$(Android Source)/ndk/source/android/libmd5/jni' and created Android.mk file with next content:

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)

LOCAL_CFLAGS := 

LOCAL_MODULE     := libmd5
LOCAL_LDLIBS     := -L$(SYSROOT)/usr/lib
LOCAL_SRC_FILES  := md5.h md5.cc

include $(BUILD_SHARED_LIBRARY) 

Then I've added next lines in the end of ~/.bashrc

    export PATH=$PATH:$HOME/AndroidSources/ndk:$HOME/bin/android-sdk-linux/tools

There is paths of NDK and SDK-tools respectively.

When I launching ndk-build I getting next thing:

andrey@andrey-desktop:~/AndroidSources/ndk/sources/android/libmd5$ ndk-build
Android NDK: WARNING: Unsupported source file extensions in jni/Android.mk for module md5    
Android NDK:   md5.h md5.cc    
make: /home/andrey/AndroidSources/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Command not found
make: /home/andrey/AndroidSources/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-gcc: Command not found
SharedLibrary  : libmd5.so
make: /home/andrey/AndroidSources/ndk/toolchains/arm-linux-androideabi-4.4.3/prebuilt/linux-x86/bin/arm-linux-androideabi-g++: Command not found
make: *** [obj/local/armeabi/libmd5.so] Error 127

When I follow to ~/AndroidSources/ndk/toolchains/arm-linux-androideabi-4.4.3/
I didn't found prebuilt directory. There including just two files: config.mk and setup.mk

However while I launching ndk-build from severally downloaded ndk-r8e I getting a very different output:

$ ndk-build
Android NDK: WARNING: Unsupported source file extensions in jni/Android.mk for module md5    
Android NDK:   md5.h   
Compile++ thumb  : md5 <= md5.cc
StaticLibrary  : libstdc++.a
SharedLibrary  : libmd5.so
Install        : libmd5.so => libs/armeabi/libmd5.so

Warning is understanding - .h files mustn't be in .mk file. However I got needest library in libs/armeabi/ (as wrote above)

I did everything with ubuntu 12.10 and got try to use ndk from android source.

What I doing wrong? How to get included shared library in self-built android? I hope I've provided information in sufficient detail. If not please ask.

Upvotes: 1

Views: 1533

Answers (1)

pt123
pt123

Reputation: 2166

you don't include header files in the LOCAL_SRC_FILES, it's only for source files

LOCAL_SRC_FILES := md5.h md5.cc

should be

LOCAL_SRC_FILES := md5.cc

you add a link to the header file (import statement) in the actual source file

Upvotes: 1

Related Questions