Using this code as an example, I have coded an implementation that
makes use of resources not exposed in the standard NDK SYSROOT,
primarily binder (using binder.h). This code compiles, but I am
struggling with linkage.
I have an issue with Lunch, so I cannot currently build the Android
sources. As an alternative, I have pulled /system/lib from a 3.1 AVD
(my target platform) and am linking against those libraries along with
those in SYSROOT. At this point I have two unresolved references, both
from the Android shared libraries:
home/parallels/jack/android_3.1_libs/libutils.so: undefined reference
to `pread64'
/home/parallels/jack/android_3.1_libs/libcutils.so: undefined
reference to `__system_property_set'
collect2: ld returned 1 exit status
make: *** [/media/JACKUBUNTU/eclipse_workspace/SemaphoreClientC/obj/
local/armeabi/SemaphoreClientC++] Error 1
libutils and libcutils are required by libbinder. I have tried various
corrections, including adding -lc to the library list.
First - being new to Android - I am hoping for a sanity check that
there is not some simpler way to achieve my goal of calling remote
services from c++. Failing that, perhaps someone could assist me in
resolving my linkage problem.
Thanking all in advance,
Brad
My Android.mk
-------------------
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := SemaphoreClientC++
LOCAL_SRC_FILES := \
SemaphoreClientC++.cpp \
SemaphoreClient.cpp \
ISemServerInterface.cpp
LOCAL_LDLIBS := \
-L/home/parallels/jack/android_3.1_libs \
-lbinder \
-lcutils \
-lutils \
-llog
include $(BUILD_EXECUTABLE)
My Application.mk
------------------------
APP_ABI := armeabi
APP_PROJECT_PATH := /home/parallels/jack/eclipse_workspace/
SemaphoreClientC
APP_CFLAGS := --sysroot=/home/parallels/android-ndk-r6b/platforms/
android-9/arch-arm -v -g -I/home/parallels/WORKING_DIRECTORY/system/
core/include -I/home/parallels/WORKING_DIRECTORY/frameworks/base/
include
--
You received this message because you are subscribed to the Google Groups "android-ndk" group.
To post to this group, send email to andro...@googlegroups.com.
To unsubscribe from this group, send email to android-ndk...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/android-ndk?hl=en.
On Nov 20, 5:31 am, David Turner <di...@android.com> wrote:
> Neither of libcutils, libutils, libbinder are exposed by the NDK, which
> means that applications should never link against them.
> Because they are not exposed, their implementation can heavily be modified
> between platform releases. This probably explain why you have a linking
> problem.
>
> I'm sorry but applications should never use the Binder from native code,
> its binary interface is (intentionally) not stable to allow this.
>
> Whatever hacks you may find on the internet, they are just that: fragile
> hacks that will break (or are already broken) in the future without notice.
>
> On Fri, Nov 18, 2011 at 9:41 PM, Brad Justice <bradleypjust...@gmail.com>wrote:
>
>
>
>
>
>
>
> > As part of a porting project I would like to call an Android remote
> > service from c++. I found some example code here:
>
> >http://www.androidenea.com/2010/03/share-memory-using-ashmem-and-bind...
So what is the recommended way to call a remote service from a C or C+
+ executable? I still need to accomplish this goal.
My guess is to call java from your c++ code; however that java method is static... so then the question becomes, how to call an android rpc from a static method?
>Dave Sparks
> More options Feb 24 2009, 7:14 pm
>For security reasons, you cannot access shared memory by name. You
>pass a file descriptor through the binder interface. See the IMemory
>implementations for examples of how ashmem is used.
Is it possible to follow this recommendation without breaking the rule
regarding use of the Binder interface from NDK code? Has anyone out
there successfully implemented shared memory?
Thanks in advance,
Brad
Dave SparksMore options Feb 24 2009, 7:14 pmFor security reasons, you cannot access shared memory by name. Youpass a file descriptor through the binder interface. See the IMemoryimplementations for examples of how ashmem is used.
Is it possible to follow this recommendation without breaking the rule
regarding use of the Binder interface from NDK code? Has anyone out
there successfully implemented shared memory?
I don't think it is possible to use shared memory in java
How to call an rpc service from a static method?
I have a test app that seems to be working well using this method.
I have published some detail here: http://interprocess-android.blogspot.com/
and plan to follow up with more detail shortly.
As I have mentioned previously, I am new to Android so comments and
advice are appreciated.
Bradley, your work is very inspiring.I spent a week on making JNI remote calls work both ways: java calling native, and native calling java.I am most grateful to Jurij Smakov for his fully explained JNI example. But JNI's GetObject, GetField, NewObject, CallMethod, and method signatures are really painful to deal with. I have hundreds of functions to export this way... I need to define an abstraction layer based on JNI to make message and signal sending (Java/Native) easier. Do you have any idea how to abstract that easily?