GrabDuck

gsoc2015_pp – genapp

:

Contents

  • Integrate Genapp-Qt4 with Airavata(0.15-release-branch) to execute long running jobs.
  • Steps to install Qt5 and have the Genapp-Qt5 version up and running.
  • Integrate Genapp-Qt5 with Airavata
  • Build Genapp-android client integrated with Airavata

Dependencies

  1. glib
  2. thrift
  3. boost (Recommended for developers)
  4. Airavata (to run the server locally)- follow tutorial

Testing Generated Interfaces

To use ready-to-run interfaces

  1. checkout code from https://github.com/priyanshu-sekhar/GenApp
  2. Go to psptest/output/qt4(or qt5)
  3. Make sure airavata-client-properties.ini in html5 folder has the correct host/port
  4. change to psptest/output and execute ./psptest/psptest

Build from Scratch

Follow the steps below to build, configure and run genapp interfaces from scratch.

  1. Set up developement environment as listed on GenApp? Wiki: http://gw105.iu.xsede.org:8000/genapp/wiki/setupdev
  2. Set GENAPP environment vairable to the location of genapp folder and add $GENAPP/bin to your PATH
  3. Change to psptest/
  4. Execute "genapp.pl"

Generated Code will be present in psptest/output

Follow the instructions below for running the specific language interfaces.

Steps to Install Qt5(for linux/X11)

  1. Download the latest Qt5 version from qt-download and run the application (Don't launch the Qt5 creator)
  2. Download the latest version of Qwt (6.1+) from qwt-install and follow the steps for installation
  3. Open terminal(from which you wish to run Genapp-Qt5)
  4. Execute the following command:
PATH=/path/to/Qt5/gcc_64/bin:$PATH && export PATH 

(Assuming qmake lies inside /path/to/Qt5/gcc_64/bin, or specify path to qmake) check "qmake -v" should display the installed version of Qt5 *

  1. Execute:
    qmake -set QMAKEFEATURES /usr/local/qwt-6.1.2/features/
    

(Replace qwt-6.1.2 with your installed version and change it's path if installed in a different directory)

Tip: You can make the PATH settings permanent by editing in the ".bashrc" or equivalent file. You are now ready to proceed with running the Qt5 application :) To link Qt statically or for other info, visit the official documentation- qt5-linux_deployment

C++/Qt4

  1. Change to "psptest/output/qt4/psptest"
  2. Execute qmake-qt4 -project
  3. Edit "psptest.pro" to add the following lines:
INCLUDEPATH += /usr/include/qwt-qt4 ../lib/
LIBS += `pkg-config --libs glib-2.0` -L/usr/local/lib -lthrift -lqwt-qt4 
QMAKE_CXXFLAGS += -w -Wall -std=c++11 -Wno-write-strings -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H  `pkg-config --cflags glib-2.0`
  1. Start your local airavata server and make sure lines 55-56 of airavata.cpp have the correct host/port
  2. Execute qmake-qt4
  3. Execute make
  4. Change to "genapp-output/psptest/output/qt4" directory
  5. Run executable ./psptest/psptest

C++/Qt5

  1. Complete the steps specified in "Steps to Install Qt5(for linux/X11)"
  2. Go to "psptest/output/qt5/psptest"
  3. Perform make clean if built previously, else skip this.
  4. Execute qmake -project
  5. Edit "psptest.pro" to add the following lines:
CONFIG += qwt
INCLUDEPATH += ../lib/
LIBS += `pkg-config --libs glib-2.0` -lthrift 
QMAKE_CXXFLAGS += -w -Wall -std=c++11 -Wno-write-strings -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H  `pkg-config --cflags glib-2.0` 
  1. Start your local airavata server and make sure lines 55-56 of airavata.cpp have the correct host/port
  2. Execute qmake -config release to statically link the Qt libraries
  3. Execute make to build and create the executable.
  4. Execute cd .. to goto "psptest/output/qt5"
  5. Run executable ./psptest/psptest

Android

To generate the android-client of Genapp integrated with Airavata, the following hurdles need to be crossed-

  1. Installation of Android-SDK and NDK tools
  2. Cross-compilation of boost with arm architecture.
  3. Cross-compilation of thrift with target architecture as arm-linux-androideabi and linux(or windows) host, in-order to run thrift APIs on Android.
  4. Linking the libraries generated, with the android application.

Build System Prerequisites

  1. Android-NDK. Download from https://developer.android.com/ndk/downloads/index.html
  2. Android-SDK(Tools only). Download form https://developer.android.com/sdk/index.html#Other
  3. Export these variables pointing to where you installed the SDK(/opt/android) and NDK(/opt/ndk).
export ANDROID_SDK=/opt/android
export ANDROID_NDK=/opt/ndk
export PATH=$PATH:$ANDROID_SDK/tools
  1. Specify the Android platform you want to build on and the directory for installation (e.g):
export PLATFORM=android-21
export INSTALL_DIR=/opt/android-toolchain
  1. Create your own tool chain using GCC 4.8( 4.9 has some issues still). To make the toolchain, run the command:
$ANDROID_NDK/build/tools/make-standalone-toolchain.sh --stl=gnustl --arch=arm --platform=$PLATFORM --abis=armeabi-v7a --install-dir=$INSTALL_DIR
  1. Update the environment variables
export ANDROID_STANDALONE_TOOLCHAIN=$INSTALL_DIR
export PATH=$ANDROID_STANDALONE_TOOLCHAIN/bin:$PATH

Dependency Setup

  1. Make a directory to install all the dependencies and make it owned by you:
sudo mkdir /opt/genapp
sudo chown user1:user1 /opt/genapp
export PREFIX=/opt/genapp

Build Libraries To run the application on GenApp? you have to cross-compile and build boost and thrift libraries. Follow the steps below:

Boost for Android

  1. Download Boost >= 1.58 from http://www.boost.org/. We have to unpack it, fix some configuration issues for Android and build:
tar xjf boost_1_58_0.tar.bz2  (use 'xzf' flags instead of 'xjf' if you have the tar.gz version. Append the 'v' flag to get verbose output)
cd boost_1_58_0
  1. Create a file called tools/build/src/user-config.jam and put the following into it:
import os ;

local ANDROID_STANDALONE_TOOLCHAIN = [ os.environ ANDROID_STANDALONE_TOOLCHAIN ] ;

using gcc : android :
     $(ANDROID_STANDALONE_TOOLCHAIN)/bin/arm-linux-androideabi-g++ :
     <compileflags>--sysroot=$(ANDROID_STANDALONE_TOOLCHAIN)/sysroot
     <compileflags>-march=armv7-a
     <compileflags>-mfloat-abi=softfp
     <compileflags>-Os
     <compileflags>-fno-strict-aliasing
     <compileflags>-O2
     <compileflags>-DNDEBUG
     <compileflags>-g
     <compileflags>-lstdc++
     <compileflags>-I$(ANDROID_STANDALONE_TOOLCHAIN)/include/c++/4.8/
     <compileflags>-I$(ANDROID_STANDALONE_TOOLCHAIN)/include/c++/4.8/arm-linux-androideabi/armv7-a
     <compileflags>-D__GLIBC__
     <compileflags>-D_GLIBCXX__PTHREADS
     <compileflags>-D__arm__
     <compileflags>-D_REENTRANT
     <compileflags>-L$(ANDROID_STANDALONE_TOOLCHAIN)/lib/gcc/arm-linux-androideabi/4.8/
     <archiver>$(ANDROID_STANDALONE_TOOLCHAIN)/bin/arm-linux-androideabi-ar
     <ranlib>$(ANDROID_STANDALONE_TOOLCHAIN)/bin/arm-linux-androideabi-ranlib
     ;
  1. Run the build scripts. You can tweak the command and choose the libraries you would like to build:
./bootstrap.sh
./b2 \
  --without-python --without-container --without-context \
  --without-coroutine --without-graph --without-graph_parallel \
  --without-iostreams --without-locale --without-log --without-math \
  --without-mpi --without-signals --without-timer --without-wave \
  link=static runtime-link=static threading=multi threadapi=pthread \
  target-os=linux --stagedir=android --build-dir=android \
  stage
  1. Now, install this library(for ARMv7-a) into our PREFIX
./b2 \
  --without-python --without-container --without-context \
  --without-coroutine --without-graph --without-graph_parallel \
  --without-iostreams --without-locale --without-log --without-math \
  --without-mpi --without-signals --without-timer --without-wave \
  link=static runtime-link=static threading=multi threadapi=pthread \
  target-os=linux --stagedir=android --build-dir=android \
  --prefix=$PREFIX install

Thrift
Follow the steps below to cross-compile thrift for Android:

OpenSSL for Android

Thrift requires some OpenSSL libraries, like libcrypto, so these need to be build installed into the toolchain.

  1. Open a new terminal. Set the toolchain bin path to the prebuilt one in the NDK:
export PATH=$ANDROID_NDK/toolchains/arm-linux-androideabi-4.8/prebuilt/linux-x86_64/bin:$PATH
  1. Download the latest stable version of OpenSSL from here. Unzip it and move to that folder.
  2. Create a script to execute the following commands( or run them independently) to build OpenSSL:
wget https://wiki.openssl.org/images/7/70/Setenv-android.sh
chmod +x Setenv-android.sh
. ./Setenv-android.sh
perl -pi -e 's/install: all install_docs install_sw/install: install_docs install_sw/g' Makefile.org
./config --prefix=/usr shared no-ssl2 no-ssl3 no-comp no-hw no-engines --openssldir=$ANDROID_STANDALONE_TOOLCHAIN/sysroot/usr/ssl/$ANDROID_API
make depend
make all
cp libcrypto.* $ANDROID_STANDALONE_TOOLCHAIN/sysroot/usr/lib
cp libssl.* $ANDROID_STANDALONE_TOOLCHAIN/sysroot/usr/lib/
ln -s `pwd`/include/openssl $ANDROID_STANDALONE_TOOLCHAIN/sysroot/usr/include

Tip :In-case you encounter any issues, follow the official documentation.

  1. Close the terminal after building successfully.

Apache Thrift

  1. Download Apache Thrift from https://thrift.apache.org/download. Here is the git command for 0.9.2 version:
git clone https://git-wip-us.apache.org/repos/asf/thrift.git thrift
cd thrift
git checkout 0.9.2
  1. Open configure.ac and comment the following lines:
    • 524 (AC_FUNC_MALLOC)
    • 526 (AC_FUNC_REALLOC)
  2. Configure and build thrift:
export SYS_ROOT="$ANDROID_STANDALONE_TOOLCHAIN/sysroot/" 
export CC="arm-linux-androideabi-g++ --sysroot=$SYS_ROOT" 
export CXX="arm-linux-androideabi-g++ --sysroot=$SYS_ROOT" 
export LD="arm-linux-androideabi-ld" 
export AR="arm-linux-androideabi-ar" 
export RANLIB="arm-linux-androideabi-ranlib" 
export STRIP="arm-linux-androideabi-strip" 
./bootstrap.sh
./configure --prefix=$PREFIX   --disable-tests --disable-tutorial --with-cpp \
 --without-python --without-c_glib --without-php --without-csharp --without-java \
 --without-libevent --without-zlib \
 --with-boost=$PREFIX --host=arm-eabi --build=x86_64-linux \
 CPPFLAGS="-I$ANDROID_STANDALONE_TOOLCHAIN/include/c++/4.8/arm-linux-androideabi/armv7-a" \
 LDFLAGS="-L$ANDROID_STANDALONE_TOOLCHAIN/arm-linux-androideabi/lib/armv7-a -lgnustl_shared" 
make
make install

Tip: Refer the official documentation and use the Mailing List to resolve your issues, if any.

  1. Check for "libthrift.a" file in $PREFIX/lib. If found, congratulations! You have built the libraries successfully.

Now, once you have completed the above steps successfully, build the application using the steps below:

Steps

  1. Go to psptest/output/qt5-android/psptest
  2. Run qmake -project. This will create the "psptest.pro" file.
  3. Launch Qt Creator.
  4. Select "Projects" from the left panel. Go to "Add Kit->Configure Android". Provide the path for "Android-NDK" and "Android-SDK" location. Click "Apply" and then "Ok".
  5. Again go to "Add Kit". This time, you should see an option "Android for armeabi-v7a (GCC x.x, Qt 5.x.x)".Select it as your deploy kit.
    Tip:The default build and run configurations should work, but you can change them to use gradle instead of ant, add the "Androidmanifest" file, adding external libraries and other cool stuff. Follow the official documentation for more details.
  6. Click File->Open File or Project. Go to "psptest/output/qt5-android/psptest" folder. Choose all the files(Ctrl+A) and click open.You should now be able to see it under the Projects window.
  7. Open "psptest.pro"(topmost file) and add the following lines:
CONFIG += qwt
INCLUDEPATH += `pkg-config --libs glib-2.0` ../lib
INCLUDEPATH += -I/usr/local/include/thrift
QMAKE_CXXFLAGS += -w -Wall -std=c++11 -Wno-write-strings -DHAVE_INTTYPES_H -DHAVE_NETINET_IN_H `pkg-config --cflags glib-2.0`
  1. Right click inside that file and select Add Library->External library. Browse the correct folders and add the following libraries:
    1. libqwt.so generated here
    2. libQt5PrintSupport.so, libQt5OpenGL.so and libQt5Concurrent.so generated here.
      Note:Look inside "../Qt5/5.4/android_armv7/lib"
    3. libthrift.a generated here
  1. That's it! Now, run the application on an emulator or Android device. Alternatively, you can use the "QtApp-debug.apk" generated inside the "build" folder created above your working directory.