BUILD_SHARED_LIBRARY and BUILD_EXECUTABLE

3,009 views
Skip to first unread message

Akshay Gattani

unread,
Jul 23, 2010, 7:27:38 PM7/23/10
to android-ndk, cry...@gmail.com
This question is for Dmitri and others who are using the Android NDK
r4-crystax-2 or Android NDK r4-crystax-3 custom NDK.

So I have the following Android.mk file (truncated for readability). I
am trying to build the eventual native module "micengine" both as a
shared library and as an executable. "micengine" depends on and is
linked with two external libraries (also built using NDK) "micnet" and
"micuuid" which are static in nature.

I understand that BUILD_EXECUTABLE is not the NDK recommended target,
but I want to generate an executable and see if can get up and running
quickly and start debugging the native app ASAP. I also understand
well how "LOCAL_LDLIBS" flags are to be used when building a shared
library that has external static library dependencies.

==============================
# Android Makefile for the MicEngine shared library

LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := micengine
LOCAL_CPP_EXTENSION := cpp
LOCAL_CFLAGS := -fPIC -Wall
LOCAL_SRC_FILES := \
AndroidEngineMain.cpp \
AndroidEvent.cpp \
AndroidExternalEvent.cpp \
AndroidFilterInterface.cpp \
AndroidLogger.cpp \
....
../MicUplinkRateShaper.cpp \
../MicUplinkScheduler.cpp \
../MicUtil.cpp

# identify the local include paths
LOCAL_C_INCLUDES := \
$(LOCAL_PATH)/. \
$(LOCAL_PATH)/../../../Common \
$(LOCAL_PATH)/../../Inc \
$(LOCAL_PATH)/../../Inc/Android \
$(LOCAL_PATH)/../../Inc/Android/external

LOCAL_STATIC_LIBRARIES := micnet micuuid
LOCAL_LDLIBS := -ldl -llog
LOCAL_LDLIBS += -L$(LOCAL_PATH)/../../Build/Android/obj/local/$
(TARGET_ARCH_ABI) -lmicnet
LOCAL_LDLIBS += -L$(LOCAL_PATH)/../../Build/Android/obj/local/$
(TARGET_ARCH_ABI) -lmicuuid

# include $(BUILD_SHARED_LIBRARY)
include $(BUILD_EXECUTABLE)

=====================

Coming to my question, I can build the "micengine" shared library
just fine, but when I buld it as an executable, i get the following
warning:

Executable : micengine
/home/mobidia/Projects/androidport/MIC/Engine/Build/Android/android-
ndk-r4-c++/build/prebuilt/linux-x86/arm-eabi-4.4.0/bin/../lib/gcc/arm-
eabi/4.4.0/../../../../arm-eabi/bin/ld: warning: libstdc++.so, needed
by /home/mobidia/Projects/androidport/MIC/Engine/Build/Android/android-
ndk-r4-c++/build/platforms/android-8/arch-arm/usr/lib/liblog.so, not
found (try using -rpath or -rpath-link)

despite the warning, i do get an final exectable. What is this warning
about and how can I get rid of the same. Whydoes liblog.so need libstdc
++.so and how can I change the LOCAL_LDLIBS, to provide the rpath-link
info the warning is requesting for.

Sorry for the long post, but hopefully someone has an idea.

Thanks,
Akshay

Dmitry Moskalchuk

unread,
Jul 24, 2010, 3:32:18 AM7/24/10
to android-ndk
Hi,

Android NDK originally included libstdc++.a/libstdc++.so at build/
platforms/android-N/arch-arm/usr/lib. This is _very_ restricted
version of C++ library; actually it contains only operator new/delete
and type_info default implementation. Library liblog.so is linked
against it. Now, look to my NDK - it remove original libstdc++.a/
libstdc++.so and use own (full) libstdc++.a instead. Of course, on
link stage libstdc++.so will not be found. But this is not problem
because libstdc++.a (linked to binary) contains all required stuff for
liblog and even more. You can safely ignore this warning. Applications
depends on liblog and compiled by my NDK just works fine.


Dmitry Moskalchuk

24.07.2010, в 3:27, Akshay Gattani написал(а):

Akshay Gattani

unread,
Jul 26, 2010, 2:43:39 PM7/26/10
to android-ndk
thats great! thanks for the reply Dmitry!

On Jul 24, 12:32 am, Dmitry Moskalchuk <crys...@gmail.com> wrote:
> Hi,
>
> Android NDK originally included libstdc++.a/libstdc++.so at build/
> platforms/android-N/arch-arm/usr/lib. This is _very_ restricted  
> version of C++ library; actually it contains only operator new/delete  
> and type_info default implementation. Library liblog.so is linked  
> against it. Now, look to my NDK - it remove original libstdc++.a/
> libstdc++.so and use own (full) libstdc++.a instead. Of course, on  
> link stage libstdc++.so will not be found. But this is not problem  
> because libstdc++.a (linked to binary) contains all required stuff for  
> liblog and even more. You can safely ignore this warning. Applications  
> depends on liblog and compiled by my NDK just works fine.
>
> Dmitry Moskalchuk
>
> 24.07.2010, × 3:27, Akshay Gattani ÎÁÐÉÓÁÌ(Á):
Reply all
Reply to author
Forward
0 new messages