Skip to content

jherkenhoff/libqalculate-android

Repository files navigation

libqalculate-android

Port of liqalculate to Android.

Importing

The library can be found in Maven Central. You can use library in your android project by declaring it as a dependency in your build.gradle file: implementation 'com.jherkenhoff:libqalculate:4.8.1-2'

Description

This is a port of libqalculate using some monkeypatching and SWIG to build it on Android.

It should implement all the features from libqalculate, and can easily sync with the latest version by modifying CMakeLists.txt.

Compiling

The project can only be built under Linux (maybe MacOS too) but not on Windows as it relies on bash shell scripts. On Windows, you can use a virtual machine.

The following instructions were tested under Ubuntu 22.04 LTS in a VirtualBox v7 virtualized environment, using Android Studio 2022.3.1:

  • Install Android Studio. Once it is installed, go into the SDK Manager, and install NDK in the Build Tools tab.
  • git clone this repository: git clone https://github.com/jherkenhoff/libqalculate-android
  • Install all the required toolchain libraries for compilation: sudo apt-get install cmake swig m4 ninja-build g++ intltool
In case of SWIG Syntax Error

Normally the following issue is fixed, but it may creep back up in the future: When building, if you get a SWIG error: Syntax Error in input(1) in includes.h, this is because there are some lines of code using some syntax that are not accepted in the newest C99 standards, so they need to be modified. The error (and link) given in the Build console in Android Studio will point directly to the problematic functions (because once one is fixed, it will jump to the next one). The issue was fixed by updating to the latest libqalculate from v4.4.0 to v4.8.1, which likely implemented syntax fixes.

Note: Don't bother modifying includes.h with #ifndef SWIG .... #endif blocks as advised here because includes.h is automatically generated from libqalculate, so instead try to fix the root cause by patching or updating to the latest libqalculate. The problematic functions were: EvaluationOptions, SortOptions, PrintOptions, InternalPrintStruct, ParseOptions

At this point, libqalculate-android should build just fine into an .aar library file that can be linked into any Android Kotlin project.

To get the app, you need to compile qalculate-android, just git clone it in a folder alongside libqalculate-android (both folders must be siblings), then try to build from qalculate-android using ./gradlew assembleDebug or via Android Studio to get an .apk file. If any issue is encountered, Build > Rebuild Project (maybe after project clean in the same menu).

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Packages

No packages published