cinemast / libjson-rpc-cpp

C++ framework for json-rpc (json remote procedure call)
MIT License
955 stars 320 forks source link

How to build libjson-rpc-cpp on Android (arm v7)? #111

Closed gogo40 closed 9 years ago

gogo40 commented 9 years ago

Hi, @cinemast

I'm developing a small app using QT5 and libjson-rpc-cpp to rpc. Currently, I'm using QT creator to generate the android version of my application, but I'm needing to link my app against your library. Someone already compiled libjson-rpc-cpp on Android?

Thank you!

gogo40 commented 9 years ago

I'm planning to create a dockerfile (like this http://vitiy.info/dockerfile-example-to-compile-libcurl-for-android-inside-docker-container/) to generate the android version of libjson-rpc-cpp. Maybe, you can add a folder docker/ with dockerfiles to cross-compiling to android, windows (using mingw32), etc. What do you think about it?

In my work, I prepared a small dockerfile to create our development environment: https://github.com/LPM-UFRGS/lpm-sandbox

cinemast commented 9 years ago

I haven't yet. Could you please post your findings back here? Maybe the ARM builds from debian could work? https://packages.debian.org/sid/libjsonrpccpp-dev

gogo40 commented 9 years ago

Hi @cinemast,

I created a small dockerfile to generate the android libs (https://github.com/cinemast/libjson-rpc-cpp/pull/112). I'm trying to build my software using QT and these libraries.

alexandre-poirot commented 9 years ago

Hi !

It might not be what you're looking for, but if you already have your toolchain for your target (I guess you have it since you're compiling Qt for Android), maybe you could override the CMAKE_CXX_FLAGS and CMAKE_C_FLAGS (and any other mandatory toolchain elements) on CMake configure in order to compile it for your target ?

That would give a : cmake .. -DCMAKE_C_FLAGS=<path to your C compiler for Android> -DCMAKE_CXX_FLAGS=<path to your C++ compiler for Android> && make instead of : cmake .. && make step in the buildind steps.

gogo40 commented 9 years ago

Hi @alexandre-poirot ,

I did a pull request (https://github.com/cinemast/libjson-rpc-cpp/pull/112/files) with a Dockerfile to prepare a complete environment to compile libjson-rpc-cpp to Android. But, currently, my app is broken... Can you to test this Dockerfile? Did you work with Android NDK already?

Thank you!

I'm having problems to compile on Visual Studio 2013 x64....

You can use the script "docker/build_android_libs.sh" to generate the libjson-rpc-cpp on Android 14 and its dependencies (the generated libraries are moved to docker/output). But, you need to install docker in your environment.

gogo40 commented 9 years ago

I think that a good way to port the lib to Android is create another client connector without dependencies with curl, libmicrohttpd, etc...

Currently, I'm not needing a server running in android, if we create a clean client connector, maybe could be more simple compile the client-side lib to android.

Another solution it's create an amalgamation with the entire library and dependencies... I'm using a sqlite amalgamation in an android ndk project and it's working very well.

I found this tool to genereate amalgamation: https://github.com/vinniefalco/Amalgamate

loreilei commented 9 years ago

Hi @gogo40 !

If you don't need the server part, have you considered tuning the configuration before build with the builld options ? (You know, the -DHTTP_SERVER=NO stuff as cmake parameter, detailled in README.md under Build / Build Options title)

cinemast commented 9 years ago

I also think, slimming down the connectors is the way to go here. Maybe by just implementing a simple TCP Server + Client.

cinemast commented 9 years ago

120 will fix this issue, once it is merged.