Raspberry cross compiling windows

Кросскомпиляция Qt 5.12 для Raspberry Pi 1,2,3 B+ под Windows

В общем на Ubuntu скомпилили, открываем пост и компилим теперь под Windows.

1. Качаем актуальную версию Raspbian и с помощью WinFLASHTool пишем её на сд карточку.

2. Так же.

3.

В дальнейшем везде будет подразумеваться х86 версия.

Качаем msys2, ставим в папку C:\SysGCC\msys2\

Качаем MinGW (у меня 730), распаковываем в папку C:\SysGCC\mingw32 с соблюдением структуры.

и остальное прописываем так же

4. Качаем тулчейн и ставим в C:\SysGCC\Raspberry

5. Запускаем C:\SysGCC\Raspberry\TOOLS\UpdateSysroot.bat, нажимаем select, подключаемся к малине (пользователь «pi» пароль «raspberry») и в список синхронизации дописываем

6. Пропускаем, за нас это сделал шаг 5.

7.

Здесь компилится для Raspberry Pi 3B+, для 1 и 2 в посте под Linux.

Если будет проблема с путями, к примеру «../../../../../../../../../../../../Raspberry/» , то Perl должен быть скачан именно по ссылке выше и в PATH идти первее всех. Ну и очищаем и заново запускаем конфигурацию.

8. так же

9. так же

10. так же

11. так же

12. так же

12.1. так же

12.2. Путь: C:\SysGCC\Raspberry\bin\arm-linux-gnueabihf-g++
ABI: arm-linux-generic-elf-32bit

12.3. Путь C:\SysGCC\Raspberry\bin\arm-linux-gnueabihf-gdb

Raspberry cross compiling windows

I have a raspberry pi 2 model b+ running with raspbian whezzy and I am trying to use cross compiling.I am using eclipse in my windows 7 pc. I have followed this webpage:

My problem is that I can not compile a Hello World code. I get this error:

15:16:46 **** Build of configuration Debug for project CrossCompileYoutube ****
make all
‘Building file: ../src/cross.cpp’
‘Invoking: Cross G++ Compiler’
arm-linux-gnueabihf-g++ -I»C:\SysGCC\Raspberry\include» -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF»src/cross.d» -MT»src/cross.o» -o «src/cross.o» «../src/cross.cpp»
‘Finished building: ../src/cross.cpp’
‘ ‘
‘Building target: CrossCompileYoutube’
‘Invoking: Cross G++ Linker’
arm-linux-gnueabihf-g++ -L»C:\SysGCC\Raspberry\include\lib» -o «CrossCompileYoutube» ./src/cross.o
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/lib/libstdc++.so: undefined reference to `clock_gettime@GLIBC_2.17′
collect2.exe: error: ld returned 1 exit status
make: *** [CrossCompileYoutube] Error 1

15:16:49 Build Finished (took 2s.971ms

I read that it is libraries problem but I do not know how I could solve it. Does someone know something about this problem?

Re: Cross Compiling Windows

I use sysGCC on Eclipse Luna on Windows 10.
I just followed the install instructions and use the managed compile (not manual make) with no problems

Читайте также:  Настройка впн соединения windows 10 сервера

The main difference between this and the standard Eclipse C/C++ manager is:
In properties C/C++ build:
Under tool chain editor set «Cross GCC»
Under Cross settings set path:» /../sysGCC» (wherever your sysGCC is)
Under prefix set «arm-linux-gnueabihf-»
Under Cross GCC Compiler set «gcc»

Re: Cross Compiling Windows

mjubes wrote: I use sysGCC on Eclipse Luna on Windows 10.
I just followed the install instructions and use the managed compile (not manual make) with no problems

The main difference between this and the standard Eclipse C/C++ manager is:
In properties C/C++ build:
Under tool chain editor set «Cross GCC»
Under Cross settings set path:» /../sysGCC» (wherever your sysGCC is)
Under prefix set «arm-linux-gnueabihf-»
Under Cross GCC Compiler set «gcc»

Where are these three option in eclipse? Project > Properties > ??

Which Raspbian version are you using? Whezzy or Jessi. Because in the example it uses Jessie and maybe this could be the problem. However, I guess that it will be possible to achieve in wheezy as well.

Re: Cross Compiling Windows

>Where are these three option in eclipse? Project > Properties > ??

Project properties. This website explains the installation in more detail:

>Which Raspbian version are you using? Whezzy or Jessi.

Both. I had whezzy when I first installed it, now I have Jessi.

Re: Cross Compiling Windows

It looks like it works! I spent a lot of hours trying it yesterday and I did not achieve, and I have achieved it in just 10 minutes today!

It compiles perfect and I will try cross compiling the raspberry on monday. I will write here.

Re: Cross Compiling Windows

Glad it was helpful

One useful thing with Eclipse, you can add to it the standard «SSH remote» plug in, and use it to easily move files to and from the RPI using drag and drop,. Also useful for compiling programs on the RPI target itself (using Eclipse just as the main editor)

Useful for writing programs that require RPI only available libraries (e.g. alsa) or low level device drivers.

Re: Cross Compiling Windows

It has been very usefull your help mjubes!

I have tried cross compiling a simple HelloWorld and it works perfect! But now I have got an other problem.

Читайте также:  Стандартный шрифт для linux

I want to use external libraries (wiringPi), so I need to add it to eclipse. I have followed this steps but I did not achieve. I copied all the library from the raspberry to my Windows PC.

1. In the project properties -> C/C++ Build->Settings->Tools Settings->Cross GCC Compiler->Includes-> Include Paths: You must insert the path for the wiringpi.h file.

In my case: C:\RaspLib\wiringPi-f6c40cb\wiringPi

2. In the project properties -> C/C++ Build->Settings->Tools Settings->Cross G++ Compiler->Includes-> Include Paths: You must insert the path for the wiringpi.h file.

In my case: C:\RaspLib\wiringPi-f6c40cb\wiringPi

3. In the project properties -> C/C++ Build->Settings->Tools Settings->Cross G++ Linker->Libraries->Libraries: You must insert «WiringPi».

4. In the project properties -> C/C++ Build->Settings->Tools Settings->Cross G++ Linker->Libraries->Library search paths: You must insert the path where there is the file
wiringpi.so .

In my case: C:\RaspLib\wiringPi-f6c40cb\wiringPi

5. In the project properties -> C/C++ General ->Path and Symbols -> Includes -> GNU C -> Add -> Library search paths

In my case: C:\RaspLib\wiringPi-f6c40cb\wiringPi

6. In the project properties -> C/C++ General ->Path and Symbols -> Includes -> GNU C++ -> Add -> Library search paths

In my case: C:\RaspLib\wiringPi-f6c40cb\wiringPi

7. In the project properties -> C/C++ General ->Path and Symbols -> Library Path -> Add -> Library search paths

In my case: C:\RaspLib\wiringPi-f6c40cb\wiringPi

11:44:17 **** Build of configuration Debug for project CrossCompile ****
make all
‘Building file: ../src/CrossCompile.cpp’
‘Invoking: Cross G++ Compiler’
arm-linux-gnueabihf-g++ -std=c++0x -I»C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\include\arm-linux-gnueabihf\c++\4.9″ -I»C:\RaspLib\wiringPi-f6c40cb\wiringPi» -O0 -g3 -Wall -c -fmessage-length=0 -MMD -MP -MF»src/CrossCompile.d» -MT»src/CrossCompile.o» -o «src/CrossCompile.o» «../src/CrossCompile.cpp»
‘Finished building: ../src/CrossCompile.cpp’
‘ ‘
‘Building target: CrossCompile’
‘Invoking: Cross G++ Linker’
arm-linux-gnueabihf-g++ -L»C:\SysGCC\Raspberry\arm-linux-gnueabihf\lib» -L»C:\RaspLib\wiringPi-f6c40cb\wiringPi» -L»C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\lib» -L»C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\lib» -o «CrossCompile» ./src/CrossCompile.o -lwiringPi
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -lwiringPi
collect2.exe: error: ld returned 1 exit status
make: *** [CrossCompile] Error 1

11:44:21 Build Finished (took 3s.663ms)

Errors:
-cannot find -lwiringPi
-make:***[crosscompile] Error 1

Does someone know why it could be??

Re: Cross Compiling Windows

I have solved the problem. I just change the name of the file libwiringPi.so.xxx that was in C:\RaspLib\wiringPi-f6c40cb\wiringPi to libwiringPi.so.

I do not know why I change it and why the problem has solved, but it worked! Does someone know the reason??

Re: Cross Compiling Windows

>I do not know why I change it and why the problem has solved, but it worked! Does someone know the reason??

Читайте также:  Iconpack для windows 10

I am not a 100% sure on this, but I suspect the appended «xxx» may have something to do with kernel version number, as linux libraries seem to be rather demanding on exact versioning.

I’ve had similar problems myself, where I had to go through a whole load of renaming and updating files when I upgraded the kernel.

What I do at present is to compile and link on the target, as it is somewhat easier to ensure all its files, source codes, compilers and libraries are up to date.

Re: Cross Compiling Windows

Waking up a dormant thread as I have a very similar issue.

I am trying to cross compile OpenCV320 on Windows for Raspberry Pi Zero (Jessie).

I’ve used the Windows toolchain for the Raspberry Pi from this location (http://gnutoolchains.com/raspberry/) and used the latest version (raspberry-gcc-4.9.2-r4.exe).

I have downloaded, built and installed opencv320 on my raspberry pi and synced the sysroot as well.

I am able to build a very simple hello world program and run it on the Pi but when I try to build the a program and reference the OpenCV libs the linker can’t find the libraries even though they are there on the Windows Host.

The error msg is as follows.

make all
‘Building file: ../src/IPWebcam.cpp’
‘Invoking: Cross G++ Compiler’
arm-linux-gnueabihf-g++ -I»C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\include» -I»C:\OpenCV3200\Unix_Build\install\include» -O0 -g3 -Wall -c -fmessage-length=0 -print-search-dirs -MMD -MP -MF»src/IPWebcam.d» -MT»src/IPWebcam.d» -o «src/IPWebcam.o» «../src/IPWebcam.cpp»
install: c:\sysgcc\raspberry\bin\../lib/gcc/arm-linux-gnueabihf/4.9/
programs: =c:/sysgcc/raspberry/bin/../libexec/gcc/arm-linux-gnueabihf/4.9/;c:/sysgcc/raspberry/bin/../libexec/gcc/arm-linux-gnueabihf/;c:/sysgcc/raspberry/bin/../libexec/gcc/;c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/arm-linux-gnueabihf/4.9/;c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/arm-linux-gnueabihf/;c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/
libraries: =c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/;c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/;c:/sysgcc/raspberry/bin/../lib/gcc/;c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/lib/arm-linux-gnueabihf/4.9/;c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/lib/arm-linux-gnueabihf/;c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/lib/;c:/sysgcc/raspberry/bin/../arm-linux-gnueabihf/sysroot/lib/arm-linux-gnueabihf/4.9/;c:/sysgcc/raspberry/bin/../arm-linux-gnueabihf/sysroot/lib/arm-linux-gnueabihf/;c:/sysgcc/raspberry/bin/../arm-linux-gnueabihf/sysroot/lib/;c:/sysgcc/raspberry/bin/../arm-linux-gnueabihf/sysroot/usr/lib/arm-linux-gnueabihf/4.9/;c:/sysgcc/raspberry/bin/../arm-linux-gnueabihf/sysroot/usr/lib/arm-linux-gnueabihf/;c:/sysgcc/raspberry/bin/../arm-linux-gnueabihf/sysroot/usr/lib/
‘Finished building: ../src/IPWebcam.cpp’
‘ ‘
‘Building target: Hello_World’
‘Invoking: Cross G++ Linker’
arm-linux-gnueabihf-g++ -L»C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\lib» -o «Hello_World» ./src/IPWebcam.o -llibopencv_calib3d -llibopencv_core -llibopencv_highgui -llibopencv_imgcodecs -llibopencv_imgproc -llibopencv_video -llibopencv_videoio -llibopencv_videostab
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -llibopencv_calib3d
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -llibopencv_core
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -llibopencv_highgui
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -llibopencv_imgcodecs
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -llibopencv_imgproc
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -llibopencv_video
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -llibopencv_videoio
c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/bin/ld.exe: cannot find -llibopencv_videostab
collect2.exe: error: ld returned 1 exit status
make: *** [Hello_World] Error 1

What I also can’t figure out is that even though I’ve use -L-L»C:\SysGCC\Raspberry\arm-linux-gnueabihf\sysroot\usr\local\lib» but still using -print-search-dirs gives the following output which shows that the linker is not looking at the path I’ve specified.
libraries: =c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/;c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/;c:/sysgcc/raspberry/bin/../lib/gcc/;c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/lib/arm-linux-gnueabihf/4.9/;c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/lib/arm-linux-gnueabihf/;c:/sysgcc/raspberry/bin/../lib/gcc/arm-linux-gnueabihf/4.9/../../../../arm-linux-gnueabihf/lib/;c:/sysgcc/raspberry/bin/../arm-linux-gnueabihf/sysroot/lib/arm-linux-gnueabihf/4.9/;c:/sysgcc/raspberry/bin/../arm-linux-gnueabihf/sysroot/lib/arm-linux-gnueabihf/;c:/sysgcc/raspberry/bin/../arm-linux-gnueabihf/sysroot/lib/;c:/sysgcc/raspberry/bin/../arm-linux-gnueabihf/sysroot/usr/lib/arm-linux-gnueabihf/4.9/;c:/sysgcc/raspberry/bin/../arm-linux-gnueabihf/sysroot/usr/lib/arm-linux-gnueabihf/;c:/sysgcc/raspberry/bin/../arm-linux-gnueabihf/sysroot/usr/lib/

I’ve updated the ld.config in the toolchain to look at my local/lib on the windows but that didn’t help either.

Out of new ideas.. can anyone point me to what might be the issue here?

Оцените статью