Pavel_47
Posts: 42
Joined: Mon Jun 12, 2017 8:34 am
Location: Switzerland

Setup Cross-Compile chain for RPi3

Tue May 28, 2019 4:42 pm

Hello,

Here is a very good manual on how to setup cross-compile chain for RPi2:
https://visualgdb.com/tutorials/raspberry/qt/embedded/

I've met problems trying to use it for RPi3.
Thus, step 12 (build the Windows tools) fails.
Two problems here:
First, there is now linux-rasp-pi3-g++ folder in ..\qt-everywhere-opensource-src-5.5.0\qtbase\mkspecs\devices to replace linux-rasp-pi2-g++ in the following command
../qt-everywhere-opensource-src-5.5.0/configure -platform win32-g++ -xplatform linux-arm-gnueabi-g++ -release -opengl es2 -device linux-rasp-pi2-g++ -sysroot C:/SysGCC/Raspberry/arm-linux-gnueabihf/sysroot -prefix /usr/local/qt5
So, used linux-rasp-pi-g++, hoping that pi means pi3.

Building process failed with the following error message:
The OpenGL ES 2.0 functionality test failed!
Use of pkg-config is not enabled, maybe you want to pass -force-pkg-config?
You might need to modify the include and library search paths by editing
QMAKE_INCDIR_OPENGL_ES2, QMAKE_LIBDIR_OPENGL_ES2 and QMAKE_LIBS_OPENGL_ES2 in
c:/Users/pyo/Downloads/qt-everywhere-opensource-src-5.5.0/qtbase/mkspecs/devices/linux-rasp-pi-g++.


The second problem - what should I modify in ...\qt-everywhere-opensource-src-5.5.0\qtbase\mkspecs\devices\linux-rasp-pi-g++\qmake.conf in order to circumvent this problem (assuming that linux-rasp-pi-g++ corresponds to RPi3).

Thasks in advance.
BR.

Pavel_47
Posts: 42
Joined: Mon Jun 12, 2017 8:34 am
Location: Switzerland

Re: Setup Cross-Compile chain for RPi3

Tue May 28, 2019 4:56 pm

I tried to find a solution on the forum Qt, but to no avail

DarkElvenAngel
Posts: 125
Joined: Tue Mar 20, 2018 9:53 pm

Re: Setup Cross-Compile chain for RPi3

Thu May 30, 2019 3:38 am

A Raspberry Pi 2 Binary should be compatible with a pi 3 are you able to build one of them? I build binaries on a pi zero and they will run on any raspberry Pi.
Give that a try.

Pavel_47
Posts: 42
Joined: Mon Jun 12, 2017 8:34 am
Location: Switzerland

Re: Setup Cross-Compile chain for RPi3

Fri May 31, 2019 6:30 am

Well ... it was old source folder.
In the new one qt-everywhere-src-5.12.3 the RPi3 device does present.
This time building the source fails due to this error:

Code: Select all

Creating qmake...
..............................c:/Users/aaa/Downloads/qt-everywhere-src-5.12.3/qtbase/src/corelib/global/qglobal.cpp:
In function 'QString qEnvironmentVariable(const char*, const QString&)':
c:/Users/pyo/Downloads/qt-everywhere-src-5.12.3/qtbase/src/corelib/global/qglobal.cpp:3346:49: error: '_wgetenv_s' was not declared in this scope
     _wgetenv_s(&requiredSize, 0, 0, wname.data());
                                                 ^
make.exe: *** [qglobal.o] Error 1
I reported this as bug to Qt bug tracker:
https://bugreports.qt.io

Pavel_47
Posts: 42
Joined: Mon Jun 12, 2017 8:34 am
Location: Switzerland

Re: Setup Cross-Compile chain for RPi3

Tue Jun 04, 2019 12:20 pm

DarkElvenAngel wrote:
Thu May 30, 2019 3:38 am
A Raspberry Pi 2 Binary should be compatible with a pi 3 are you able to build one of them? I build binaries on a pi zero and they will run on any raspberry Pi.
Give that a try.
What source did you use ?

DarkElvenAngel
Posts: 125
Joined: Tue Mar 20, 2018 9:53 pm

Re: Setup Cross-Compile chain for RPi3

Fri Jun 14, 2019 4:09 am

I'm speaking in general, I write code on my pi0w and compile it there. From that build I can deploy and run that code on any pi including a pi3 b+.

As long as you have the correct libraries installed you shouldn't have problems.

When cross compiling you need to be sure that the library versions in your toolchain match what is on the target device. Personally I find cross compiling tedious to work with especially on Windows there's always something out of sync.

Sorry I don't have the answer your looking for but I thought if you could follow the guild and build for a pi 2 or even a pi 1 you'd have something useable.

jahboater
Posts: 4429
Joined: Wed Feb 04, 2015 6:38 pm

Re: Setup Cross-Compile chain for RPi3

Fri Jun 14, 2019 7:27 am

DarkElvenAngel wrote:
Fri Jun 14, 2019 4:09 am
I'm speaking in general, I write code on my pi0w and compile it there. From that build I can deploy and run that code on any pi including a pi3 b+.
The Pi Zero is pretty slow, so I write the code and debug it on a Pi 3B+ or an Intel PC.
My makefile sets the optimal compiler flags for each platform automatically (messy syntax but it works).

Code: Select all

#
#  Detect hardware.
#
machine = $(shell sh -c 'uname -m 2>/dev/null || echo unknown')

#
#  Compiler, C standard, Platform etc
#
CC = gcc -std=gnu18
CPU = -march=native -mtune=native
PLATFORM = -funsigned-char -pipe
WARN = -Wall -Wextra -Wconversion -Wuninitialized -Wcast-qual -Wcast-align -Wwrite-strings \
       -Wformat -Wpointer-arith -Wlogical-op -Wundef -Wredundant-decls -Wunused -Wunused-macro \
       -Wunused-parameter -Wpacked -Wno-char-subscripts -Wno-switch -Werror -Wfatal-errors

# Intel x64
ifneq (,$(findstring x86,$(machine)))
  PLATFORM += -malign-data=abi -mstringop-strategy=rep_8byte
endif

# Raspberry Pi B+, Zero, etc
ifneq (,$(findstring armv6l,$(machine)))
  CPU = -mcpu=arm1176jzf-s -mtune=arm1176jzf-s -mfpu=vfp
  PLATFORM += -mhard-float -mfloat-abi=hard -mlittle-endian
endif

# Raspberry Pi 2, 3  and 3+ (add -mthumb for compressed executable)
ifneq (,$(findstring armv7l,$(machine)))
  CPU = -mcpu=cortex-a53 -mtune=cortex-a53 -mfpu=neon-fp-armv8
  PLATFORM += -mneon-for-64bits -mhard-float -mfloat-abi=hard -mlittle-endian
endif

# ARM aarch64 - 64-bit NEON is mandated
ifneq (,$(findstring aarch64,$(machine)))
  CPU = -mcpu=cortex-a73 -mtune=cortex-a73
  PLATFORM += -mabi=lp64 -mcmodel=tiny -mlittle-endian
endif

OPT = $(CPU) $(PLATFORM) $(USER_OPT) $(WARN)

DarkElvenAngel
Posts: 125
Joined: Tue Mar 20, 2018 9:53 pm

Re: Setup Cross-Compile chain for RPi3

Fri Jun 14, 2019 2:55 pm

You are right jahboater the pi zero is slow I mostly use it over ssh from my pi 3B+ and use Genie to edit and write the bulk of my code, I also use nano directly on the zero.

It might seem strange not to just use the more powerful pi to do the compile however I'm not ever compiling anything that take more than a minute. The added features of having all the dev resources and man pages installed on the zero means I can grab a small device that's ultra portable and my netbook and still have everything I need to work when not at home.

Return to “C/C++”