Building qtcontribs for Android from OSX

99 views
Skip to first unread message

Antonio Linares

unread,
Mar 8, 2019, 5:42:04 AM3/8/19
to QtContribs
As QT Creator changes as Android Studio, etc. change too, the best way to find the right flags is to create a project with QT Creator and review the used flags in the generated Makefile

Also I have found that building Harbour on Android itself (using termux) is simpler (can't build qtcontribs there, thats the disadvantage)

go.sh

export HB_PLATFORM=android
export HB_COMPILER=gcc
export HB_INSTALL_PREFIX=/Users/$USER/harbour
export HB_HOST_BIN=/Users/$USER/harbour/bin/darwin/clang

export QT_PATH=/Users/$USER/Qt/5.12.1/android_armv7
export HB_WITH_QT=$QT_PATH/include
export HB_QTPATH=$QT_PATH/bin

export CXXFLAGS=-D__ANDROID_API__=16 -target armv7-none-linux-androideabi -gcc-toolchain /Users/$USER/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 -DANDROID_HAS_WSTRING --sysroot=/Users/$USER/Library/Android/sdk/ndk-bundle/sysroot -isystem /Users/$USER/Library/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -isystem /Users/$USER/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include -isystem /Users/anto/Library/Android/sdk/ndk-bundle/sources/android/support/include -isystem /Users/$USER/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++abi/include -fstack-protector-strong -DANDROID -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -fno-builtin-memmove -mthumb -Oz -Wall -W -D_REENTRANT -fPIC $(DEFINES)
export INCPATH=-I/Users/$USER/Qt/5.12.1/android_armv7/include -I/Users/$USER/Qt/5.12.1/android_armv7/include/QtPrintSupport -I/Users/$USER/Qt/5.12.1/android_armv7/include/QtWidgets -I/Users/$USER/Qt/5.12.1/android_armv7/include/QtGui -I/Users/$USER/Qt/5.12.1/android_armv7/include/QtNetwork -I/Users/$USER/Qt/5.12.1/android_armv7/include/QtCore -I. -I/Users/$USER/Qt/5.12.1/android_armv7/mkspecs/android-clang 

export HB_INCLUDE="/Users/$USER/harbour/contrib/qtcontribs/hbqt/qtgui"
export HB_USER_CFLAGS="-std=c++11 $CXXFLAGS $INCPATH"
export HB_USER_CXXFLAGS="-std=c++11 $HB_USER_CFLAGS"

# make clean
# make

/Users/$USER/harbour/bin/darwin/clang/hbmk2 qtcontribs.hbp -I$HB_INCLUDE 

best regards

Antonio Linares

Antonio Linares

unread,
Mar 8, 2019, 6:21:18 PM3/8/19
to QtContribs
There were some errors in my previous post. This one is ok:

export HB_PLATFORM=android
export HB_COMPILER=gcc
#export HB_CCPREFIX=/Users/anto/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64/bin/arm-linux-androideabi-
export HB_INSTALL_PREFIX=/Users/anto/harbour
export HB_HOST_BIN=/Users/anto/harbour/bin/darwin/clang

export QT_PATH=/Users/$USER/Qt/5.12.1/android_armv7
export HB_WITH_QT=$QT_PATH/include
export HB_QTPATH=$QT_PATH/bin

export CXXFLAGS="-D__ANDROID_API__=16 -target armv7-none-linux-androideabi -gcc-toolchain /Users/$USER/Library/Android/sdk/ndk-bundle/toolchains/arm-linux-androideabi-4.9/prebuilt/darwin-x86_64 -DANDROID_HAS_WSTRING --sysroot=/Users/$USER/Library/Android/sdk/ndk-bundle/sysroot -isystem /Users/$USER/Library/Android/sdk/ndk-bundle/sysroot/usr/include/arm-linux-androideabi -isystem /Users/$USER/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++/include -isystem /Users/anto/Library/Android/sdk/ndk-bundle/sources/android/support/include -isystem /Users/$USER/Library/Android/sdk/ndk-bundle/sources/cxx-stl/llvm-libc++abi/include -fstack-protector-strong -DANDROID -march=armv7-a -mfloat-abi=softfp -mfpu=vfp -fno-builtin-memmove -mthumb -Oz -Wall -W -D_REENTRANT -fPIC"
export INCPATH="-I/Users/$USER/Qt/5.12.1/android_armv7/include -I/Users/$USER/Qt/5.12.1/android_armv7/include/QtPrintSupport -I/Users/$USER/Qt/5.12.1/android_armv7/include/QtWidgets -I/Users/$USER/Qt/5.12.1/android_armv7/include/QtGui -I/Users/$USER/Qt/5.12.1/android_armv7/include/QtNetwork -I/Users/$USER/Qt/5.12.1/android_armv7/include/QtCore -I. -I/Users/$USER/Qt/5.12.1/android_armv7/mkspecs/android-clang" 

export HB_INCLUDE="/Users/$USER/harbour/contrib/qtcontribs/hbqt/qtgui;/Users/$USER/harbour/contrib/qtcontribs/hbqt/qtcore"
export HB_USER_CFLAGS="-std=c++11 $CXXFLAGS $INCPATH"
export HB_USER_CXXFLAGS="-std=c++11"

#make clean
#make

/Users/$USER/harbour/bin/darwin/clang/hbmk2 qtcontribs.hbp -I$HB_INCLUDE 

Please notice that -std=c++11 has to be removed when a C from PRG file is being compiled, but added when a QT C file is compiled. 
I have not found a way to automatize this.

Once the libraries are build, delete them, uncomment HB_CCPREFIX and run this script again, so the right "ar" is used

You may download the libraries already built from here:

Pritpal Bedi

unread,
Mar 31, 2019, 8:33:10 PM3/31/19
to QtContribs
Thanks Antonio

It will be useful for many.

>Please notice that -std=c++11 has to be removed when a C from PRG file is being compiled, but added when a QT C file is compiled. 
>I have not found a way to automatize this.

I think I have discovered a work-around which will be there in next commit.
This fix was discovered when I was experimenting with WebAssembly.


Pritpal Bedi

Reply all
Reply to author
Forward
0 new messages