简体   繁体   中英

C++ library for mobile application

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:

  1. Blackberry
  2. iPhone
  3. 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++.

: 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/

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

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).

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM