I have my own C++ library with source code. It contains functions like this: CreateDvice, FillDevice, CloseDevice and etc. There is no dependency to any third-party libraries.
There is requirement to create application for mobile platform:
Blackberry
iPhone
Android
The application has to use logic provided by this library.
Is there chance to use existing library in mobile application or at least some of them?
Or does it require to re-implement library code for each platform?
For iOS (iPhone/iPad) you can directly compile your library and use it from a regular iOS app written in Objective-C++ and/or C++.
For Android you can directly compile your library using the NDK, then either write your app in Java and call your library via JNI, or write the whole app in C++ using the NDK.
I believe you are out of luck on Blackberry, for this platform you'll need to rewrite your library in Java, as neither apps or libs can be written in C++.
Edit: See my other answer for a completely different approach that may work for you.
Blackberry:
It's technically possible to have ASM on BlackBerry (or Android, iPhone, etc.) but 3rd-party developers are often not allowed (or not able in the case of BlackBerry) to do so.
iPhone:
Absolutely. You can statically link a C++ library. Of course it will have to be compiled with the right instruction set. There are a host of examples out there on how to do this. Translate - you will need the code.
Android:
Absolutely. There is a good book on this by Mark Murphy. Introductory material here:
http://www.androidguys.com/2009/10/14/android-beyond-java-part-one/
Your question is unclear. Do you need a cross-platform library/engine to create a mobile application?
If it is so, Cocos2D would be the best choice. Originally it's a game engine, but it is suitable for applications too. And it supports all the platforms written above.
Instead of compiling your C++ library on each target device that you intend to support, you could opt for creating a service that packs your library. You can install this library on a host you have control, then from each platform the only thing you need to do is invoke this service.
I'm not sure if this thing makes sense for the kind of library that you have, but this would be a way to maintain a single version of your library, and you'll have a guaranteed same behavior on all devices.
Good luck.
Android is not natively Java, it's natively C++. And iOS is also natively C++. So why not just leave the C++ code untouched and drop RIM's current platform (since they are switching to BBX which does support C++ as well).
For Blackberry you can use the C++/Qt Cascades; for iOS you can use C/C++ & Objective-C (a superset of C) and Android can use the C++ NDK. You can use Java on all platforms as long as the Java apps are standalone and the JRE is pre-packaged with the app (iOS). You can interface with C/C++ libs using JNI
If you want to use a Java library on all platforms, that would work.
Android and Blackberry are natively Java.
You can use a tool called XMLVM to cross-compile your Java library to Objective C for use on iOS.
http://xmlvm.org/overview/
It is not 100% perfect, but pretty darn close. We use it extensively to port common Java library code to iOS. Port the C++ library to Java and you are good to go.
Related
How I can use a Lisp library in Android (Eclipse Java)?
For example I like have a "Intelligent apps" with Lisp.
You need or common lisp implementation, which can run under android, or some tool to compile common lisp code into JVM Bytecode or native library for android (with NDK). As far as I know, there is no good and free solution for this problem for now.
Clozure Common Lisp can run under android, but you can't really create an application which can be published in play store with it. Or it'll be very difficult. There is even an example for CCL on android.
There is also proprietary Common Lisp implementation from wukix - MOCL, which aims to be able to bring Common Lisp into mobile development world. I had no experience with that, you can give it a try.
As I said, looks like for now there is no easy way to do what you want.
LambdaNative is technically a lisp (it is an implementation of Scheme based on Gambit-C Scheme) which implements its own GUI and various other modules.
It uses the same source code to create native applications for Android, iOS, Linux, Mac OS X, Blackberry 10, Windows, OpenBSD and OpenWrt.
Try lispworks android/ios runtime:
Sad thing it's not free, but you can ask for evaluation license.
Useful links:
Build iOS/Android Libraries in Common Lisp with LispWorks
LispWorks® for Mobile Runtime
LispWorks User Guide and Reference Manual- 16 Android interface
Mocl is another alternative:
mocl (+ lisp ios android osx)
There is also eql5-android, which integrates QML for the UI. It features a few examples.
I need to create an API library for Android and iOS. I have experience working with Android projects, but zero experties in iOS. I was wondering if I could create a Project library in Xamarin that compiles as a JAR for Android and as an... I-don't-know-which-type for iOS.
No, that isn't possible. Depending on what you are trying to accomplish there may be alternatives. If you are trying to make a library that can be used by others you could make it a Xamarin component - there is a component store you could put it on if you want it to be generally available, otherwise you can use any normal means of source or object distribution.
If you need to interact with a native app/library then you could make the C# code the "owner" of it and have it call into the native code. This works for both IOs and Android (and is used to work with e.g the play services from google).
No, it is unfortunately not possible to do that.
It seems to me that what you need is a Portable Class Library also known as PCL. It allows you to create a project which can be referenced by all Xamarin supported platforms (such as iOs and Android). There are obviously limitations to the approach like not being able to reference platform specific libraries but in your case (of writing an API) it should suffice.
You can read more in this link
Good Luck!
Question:
What is the suggested way to customize native components of Android for inclusion in an Android app? By "native components" I mean components for which the native source code is available in AOSP - but which use API's not exposed in the NDK documentation.
Details:
I want to use a simplified version of the Android media framework (actually, all I need is the NuPlayer to play an RTSP stream for my app). I know this sort of customization involves using the native code (frameworks/base/media) from AOSP, modifying what I need; and building this to generate the .so file as per my needs. I then do a System.loadLibrary() plus JNI.
My question is - what is the suggested way to do this?
I cannot use the NDK (rather, I am not supposed to use NDK) since many of the API's used in the media framework are not exposed to the NDK. But then, how do I build my modified media framework code? I do see Android.mk files in there. What do I use to build these?
Your question is self-contradictory: you want to customize native components of Android, without use the NDK. NDK stands for Native Development Kit: I have heard no one developing native components without using Native Development tools. And the NDK is the easiest one to use...
IMHO, your real problem lies in this statement: I cannot use the NDK (rather, I am not supposed to use NDK). Here I ask: why?
In order for reuse ability on iOS, I would like to write the logic for my Android game in C++ rather than java. How can I create a C++ class in eclipse and integrate it into my application?
I have read "native C++ code can be used on Android as well using the Native Development Kit (NDK)". What is the latest and greatest way to do this? I am writing a simple OpenGL app? Are there any tutorials out there that people have found useful?
Thanks very much.
Investigate using the JNI and NDK here:
http://developer.android.com/sdk/ndk/index.html
I have written a multi platform 2D engine that runs on a fair amount of platforms. It's possible to do though not relatively easy to implement.
The way I did it was split it up in 2 parts where I used Java for the Activity lifecycle and some additional assist functionality and library encapsulated C++ code for all the rest.
For the C++ I used the JNI where I had two shared libraries. One library held the core logic that ran the entire game and then the other library was a sort of passthrough library with a couple of methods that were called from Java. This way, I could just recompile the core library on each platform without a lot of difficulties and I could rewrite the UI section for each platform. On iOS, I wrote it in Obj-C, on android in Java and on Windows in C/C++.
I face a problem while developing a native C/C++ shared library for Android platform. As we all know that Android use Java language for the upper layer development. Now I have ported my Engine code using ASCII C/C++ to Android using its bionic library, yet when need to design the User Interface, I have to use the JNI to call my engine code.
As far as I know, that is the only choice. The problem is my engine own hundreds of export APIs. If I use the JNI tech. I need to wrap these APIs to a new shared library for use, which will cost a lot of time for development and testing.
Can somebody give some suggestions for this situation? I am not familiar with java or JNI tech by the way.
TIPS:
When I searched the internet, I found some open source for JNI generator such as JNative etc. Until now I do not know is it suitable for Android platform or not.
You can easily use SWIG www.swig.org which will generate the JNI bindings for you.
there is nothing android-specific in that operation, so it will work rather out-of-the-box.