-Mark
Regards,
Nalin
> --
> 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.
>
>
-Seb
Yes the NDK supports C and C++, so long as you link to the proper
library. However, you can't just expect your Unix projects to compile.
The NDK is limited in many respects, for example, the STL has no
exceptions last I checked.
Refer to the Documentation in the NDK
directory. It explains the limitations of the NDK.
-Seb
On Dec 16, 10:43 am, Mark Winchester <mwinches...@gmail.com> wrote:
> Does the NDK support mixed C/C++ projects? I've got a project that
> utilizes static libraries written in both C and C++. I'm having a
> hell of a time trying to get them to compile with the ndk-build
> command. These are existing Unix projects, so I'm scratching my head
> about why they aren't working. Any advice?
>
> -Mark
Sharing data between 2 apps is possible, as far as I read about Android
UID and content provider.
The content provider is a light SQL database, but for sharing just a
variable or array it's kinda overkill not?
Is there not another way to share data between apps with use of UID and
a few java / jni function calls?
Greetings,
Cwli
Android.mk:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := cppLib
LOCAL_SRC_FILES := ./CppCode/cppFunction.cpp
include $(BUILD_STATIC_LIBRARY)
#-------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := cLib
LOCAL_SRC_FILES := ./CCode/cfunction.c
include $(BUILD_STATIC_LIBRARY)
#-------------------------------------------------
include $(CLEAR_VARS)
LOCAL_MODULE := sharedLib
LOCAL_SRC_FILES := \
./SharedCode/SharedSource.cpp
LOCAL_STATIC_LIBRARIES := \
cppLib \
cLib
include $(BUILD_SHARED_LIBRARY)
./CCode/cfunction.c
#include "cfunction.h"
int cFunction(int parama, int paramb)
{
int retVal;
retVal = parama + paramb;
return(retVal);
}
./CppCode/cppFunction.cpp:
#include "cppFunction.h"
int cppFunction(int parama, int paramb)
{
int retVal;
retVal = parama - paramb;
return(retVal);
}
./SharedCode/SharedSource.cpp
#include "../CCode/cfunction.h"
#include "../CppCode/cppFunction.h"
int SharedFunction (void)
{
int cppResult, cResult;
cppResult = cppFunction(54, 38);
cResult = cFunction(3, 9);
return(cppResult - cResult);
}
When I try to build this project, I get an error that the reference to
cFunction(int, int) is undefined. What's odd, though, is that if I
rename cfunction.c to cfunction.cpp, it all compiles fine. This is
the output from the ndk-build:
Compile++ thumb : sharedLib <= SharedSource.cpp
Compile++ thumb : cppLib <= cppFunction.cpp
StaticLibrary : libcppLib.a
Compile thumb : cLib <= cfunction.c
StaticLibrary : libcLib.a
SharedLibrary : libsharedLib.so
./obj/local/armeabi/objs/sharedLib/./SharedCode/SharedSource.o: In
function `SharedFunction()':
/Android/Workspace/CExperiment/jni/./SharedCode/SharedSource.cpp:9:
undefined reference to `cFunction(int, int)'
collect2: ld returned 1 exit status
make: *** [obj/local/armeabi/libsharedLib.so] Error 1
Any help would be appreciated.
-Mark
-Mark
-Mark
On Dec 19, 9:20 am, David Turner <di...@android.com> wrote:
> The problem is in no way related to the NDK, it's a basic C++ name mangling
> issue.
>
> If you want to call a C function from C++, you need to ensure that its
> declaration in C++ uses C-linkage (usually with 'extern "C" ...")
>
> Seehttp://www.parashift.com/c++-faq-lite/mixing-c-and-cpp.html