QT cross compiler for ARM

Post Reply
marius
Site Admin
Posts: 18
Joined: Tue Sep 10, 2019 2:21 pm

QT cross compiler for ARM

Post by marius » Wed Oct 09, 2019 1:30 pm

Reference procedure post

We build the QT qmake for beaglebone.

Save ./qtbase/mkspecs/devices/linux-beagleboard-g++/qmake.conf to a backup file and replace with this.

Code: Select all

#
# qmake configuration for the BeagleBoard and BeagleBoard xM boards
# http://beagleboard.org/

MAKEFILE_GENERATOR = UNIX
CONFIG += incremental
QMAKE_INCREMENTAL_STYLE = sublib

include(../../common/linux.conf)
include(../../common/gcc-base-unix.conf)
include(../../common/g++-unix.conf)

load(device_config)

QT_QPA_DEFAULT_PLATFORM = eglfs

# modifications to g++.conf
QMAKE_CC = $${CROSS_COMPILE}gcc
QMAKE_CXX = $${CROSS_COMPILE}g++
QMAKE_LINK = $${QMAKE_CXX}
QMAKE_LINK_SHLIB = $${QMAKE_CXX}

# modifications to linux.conf
QMAKE_AR = $${CROSS_COMPILE}ar cqs
QMAKE_OBJCOPY = $${CROSS_COMPILE}objcopy
QMAKE_NM = $${CROSS_COMPILE}nm -P
QMAKE_STRIP = $${CROSS_COMPILE}strip

COMPILER_FLAGS = -march=armv7-a -mtune=cortex-a8 -mfpu=neon -mthumb -fPIC
#modifications to gcc-base.conf
QMAKE_CFLAGS += $${COMPILER_FLAGS}
QMAKE_CXXFLAGS += $${COMPILER_FLAGS}
QMAKE_CXXFLAGS_RELEASE += -O3

# ROOT_FS
# mco-mco
# SET(LDFLAGS "-Wl,-rpath-link,$(ROOT_FS)/lib/arm-linux-gnueabihf")
# mco-mco


# /usr/lib/arm-linux-gnueabihf/
#./usr/lib/arm-linux-gnueabihf/libxcb.so.1
# ./lib/libxcb.so.1

QMAKE_LFLAGS += "-Wl,-rpath-link,$(ROOT_FS)/lib/arm-linux-gnueabihf,-rpath-link,$(ROOT_FS)/usr/lib/arm-linux-gnueabihf"
#QMAKE_LFLAGS += "-Wl,-rpath-link,-rpath-link,$(ROOT_FS)/usr/lib/arm-linux-gnueabihf,$(ROOT_FS)/lib/arm-linux-gnueabihf"
QMAKE_LFLAGS += -L$(ROOT_FS)/lib
QMAKE_LFLAGS += -L$(ROOT_FS)/lib/arm-linux-gnueabihf
QMAKE_LFLAGS += -L$(ROOT_FS)/usr/lib
QMAKE_LFLAGS += -L$(ROOT_FS)/usr/lib/arm-linux-gnueabihf

QMAKE_LIBS += -lrt -lpthread -ldl -fPIC

# Extra stuff (OpenGL, DirectFB, ...)
QMAKE_INCDIR_EGL = $(ROOT_FS)/usr/include
QMAKE_INCDIR_EGL += $(ROOT_FS)/usr/include/GL
QMAKE_INCDIR_EGL += $(ROOT_FS)/usr/include/GLES
QMAKE_INCDIR_EGL += $(ROOT_FS)/usr/include/GLES2
QMAKE_INCDIR_EGL += $(ROOT_FS)/usr/include/EGL
QMAKE_LIBDIR_EGL += $(ROOT_FS)/usr/lib/arm-linux-gnueabihf/
QMAKE_LIBDIR_EGL += $(ROOT_FS)/usr/lib
QMAKE_LIBDIR_EGL += $(ROOT_FS)/lib/


QMAKE_INCDIR_OPENGL_ES2 = $${QMAKE_INCDIR_EGL}
QMAKE_LIBDIR_OPENGL_ES2 = $${QMAKE_LIBDIR_EGL}
QMAKE_INCDIR_OPENVG = $${QMAKE_INCDIR_EGL}
QMAKE_LIBDIR_OPENVG = $${QMAKE_LIBDIR_EGL}

QMAKE_LIBS_EGL = -lEGL -lIMGegl -lsrv_um
QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 $${QMAKE_LIBS_EGL}
QMAKE_LIBS_OPENVG =
# -lOpenVG $${QMAKE_LIBS_EGL}

#DISTRO_OPTS +=  soft-float
DISTRO_OPTS += hard-float

# No need for any special EGL device integration.
# Prioritize the default, compiled-in integration over any plugins.
EGLFS_DEVICE_INTEGRATION = none

include(../common/linux_arm_device_post.conf)

load(qt_config)
  • Patch this file manually at the lines where you see mco-mco
./qtbase/src/corelib/global/qglobal.h:

Code: Select all

/*
   Avoid "unused parameter" warnings
*/
#define Q_UNUSED(x) (void)x;

#if defined(__cplusplus) && defined(Q_COMPILER_STATIC_ASSERT)
#  define Q_STATIC_ASSERT(Condition) static_assert(bool(Condition), #Condition)
#  define Q_STATIC_ASSERT_X(Condition, Message)// static_assert(bool(Condition), Message) mco-mco
#elif defined(Q_COMPILER_STATIC_ASSERT)
// C11 mode - using the _S version in case <assert.h> doesn't do the right thing
#  define Q_STATIC_ASSERT(Condition) _Static_assert(!!(Condition), #Condition)
#  define Q_STATIC_ASSERT_X(Condition, Message) _Static_assert(!!(Condition), Message)
#else
// C89 & C99 version
#  define Q_STATIC_ASSERT_PRIVATE_JOIN(A, B) Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B)
#  define Q_STATIC_ASSERT_PRIVATE_JOIN_IMPL(A, B) A ## B
#  ifdef __COUNTER__
#  define Q_STATIC_ASSERT(Condition) \
    typedef char Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __COUNTER__) [(Condition) ? 1 : -1];
#  else
#  define Q_STATIC_ASSERT(Condition) \
    typedef char Q_STATIC_ASSERT_PRIVATE_JOIN(q_static_assert_result, __LINE__) [(Condition) ? 1 : -1];
#  endif /* __COUNTER__ */
#  define Q_STATIC_ASSERT_X(Condition, Message)// Q_STATIC_ASSERT(Condition) mco-mco
#endif

#ifdef __cplusplus

  • Use this configure . Create a bash file called configqt.sh in SDK folder and put this content

Code: Select all

#!/bin/bash

#./mkspecs/devices/linux-beagleboard-g++/
BBB_SDK=$(pwd)
TC=${BBB_SDK}/gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf
ROOT_FS=${BBB_SDK}/debfs
export ROOT_FS=${BBB_SDK}/debfs

pushd qt5

git clean -dfx
echo ${BBB_SDK}
echo ${ROOT_FS}
echo ${PATH}

export PATH=${TC}/bin/:$PATH
export LD_LIBRARY_PATH=$ROOT_FS/usr/lib/arm-linux-gnueabihf:$ROOT_FS/lib/arm-linux-gnueabihf:$LD_LIBRARY_PATH:
export LDFLAGS='-L${ROOT_FS}/usr/lib/arm-linux-gnueabihf -L${ROOT_FS}/lib/arm-linux-gnueabihf'
export CFLAGS='-L${ROOT_FS}/usr/lib/arm-linux-gnueabihf -L${ROOT_FS}/lib/arm-linux-gnueabihf'
export BBB_TC=arm-linux-gnueabihf-

#./configure -platform linux-g++ -opengl es2 -device linux-beagleboard-g++ -device-option CROSS_COMPILE=$BBB_TC -sysroot $ROOT_FS -opensource -confirm-license -make libs -prefix $ROOT_FS -extprefix $ROOT_FS -hostprefix $ROOT_FS -v -no-gbm --enable-static --enable-shared

./configure -platform linux-g++ --enable-shared --enable-static -opengl es2 \
-device linux-beagleboard-g++ -device-option CROSS_COMPILE=$BBB_TC \
-sysroot $ROOT_FS -opensource -confirm-license -make libs -prefix $ROOT_FS \
-extprefix $ROOT_FS -hostprefix $ROOT_FS -v -no-gbm -skip qtserialbus \
-skip qtscxml -skip qtscript -skip qtcharts -skip qt3d -skip qtdatavis3d \
-skip qtcanvas3d -skip qtgamepad -skip qtvirtualkeyboard -skip qtwayland \
-skip qtwebengine -skip qtwebchannel -skip qtwebglplugin -recheck-all \
-no-qml-debug -nomake examples -nomake tests -no-pulseaudio -no-alsa


popd


  • Now make it runable and run it

Code: Select all

chmod +x *.sh
./configqt.sh 
  • Now cd to qt5

Code: Select all

export PATH=<full-path-to>/gcc-linaro-6.4.1-2017.11-x86_64_arm-linux-gnueabihf/bin:$PATH
make
find -name qmake  # this is the one
On BBB

Configuring qtcreator

... in progress.. briefly goes like this
Options:
  • New device: bare metel ssh credentials
  • Compiler: select arm G++ cna GCC compiler from toolchain (give it a name)
  • Debuger: select debuger from toolchain (give it a name)
  • Qt Versions: Manual: select qmake from SDK/qt5/bin/qmake folder
  • Kits: Make a new kit, pick a name
  • -select compilers, debuggers, qtversion th eone you did, root system file the SDK/debfs folder
In *.pro file do this

Code: Select all


QMAKE_LFLAGS += "-Wl,-rpath-link,/full-path-to-rootfile-system/debfs/lib/arm-linux-gnueabihf,-rpath-link,/full-path-to-rootfile-system/debfs/usr/lib/arm-linux-gnueabihf"


# at the bottom add desired libraries. -lm is somehow mandatory
LIBS += -ldl -lpthread -lm




Post Reply