How to get arm-none-eabi-gcc.exe from source code

Asked by yu

Hi all,

"How to build toolchain.pdf" only express the process of building cross compiler on Linux and Mac.

Do you know how to compile the cross compiler from source code on Windows?
Or, do you have the source code for gcc-arm-none-eabi-5_4-2016q3-20160926-win32.exe?

I want to build arm-none-eabi-gcc.exe from source code on Windows.

Thank you very much!
Best,
yu

Question information

Language:
English Edit question
Status:
Solved
For:
GNU Arm Embedded Toolchain Edit question
Assignee:
No assignee Edit question
Solved by:
yu
Solved:
Last query:
Last reply:
Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#1

Hi Yu,

We build the Windows toolchain on Linux using mingw. The build-toolchain.sh script will do both a build for Linux and for Windows when run on Linux. You need special option (--skip_steps=mingw32) to *not* build a Windows toolchain.

Best regards.

Revision history for this message
yu (peace567) said :
#2

I run build-toolchain.sh without option --skip_steps=mingw32, but I cannot find the exe files

yu@ubuntu:~/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926$ find ./ -name arm-none-eabi-gcc
./build-native/target-libs/bin/arm-none-eabi-gcc
./install-native/bin/arm-none-eabi-gcc

These two binaries are for linux, not for windows.

Do you know where the windows exe files locate?

Thank you very much!
Best,
yu

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#3

Hi Yu,

The result (both for Linux and Windows) of the build should be in the pkg directory.

Best regards.

Revision history for this message
yu (peace567) said :
#4

Hi Thomas,

There is nothing in pkg directory.
Could you please tell me how you build arm-none-eabi-gcc.exe from source?

Thanks you very much!
Best,
yu

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#5

Hi Yu,

Following exactly the build instructions work for us. Please provide us the log of the build [1] if you want people to be able to help you.

[1] Run build-prerequisites and build-toolchain in this way:
./build-prerequisites.sh | tee build.log
./build-toolchain.sh | tee -a build.log

Please note the -a for the second line, otherwise it is going to overwrite the log from the first line.

Best regards.

Revision history for this message
yu (peace567) said :
#6

Hi Thomas,

Here is the last step of build.log. The building of Task [II-0] fails. I do the build manually under zlib folder, it success.
Do you know what's wrong here?
Thank you very much!
Best,
yu
-----------------------------------------------------------------
......
Libraries have been installed in:
   /home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/build-native/host-libs/usr/lib

If you ever happen to want to link against installed libraries
in a given directory, LIBDIR, you must either use libtool, and
specify the full pathname of the library, or use the `-LLIBDIR'
flag during linking and do at least one of the following:
   - add LIBDIR to the `LD_LIBRARY_PATH' environment variable
     during execution
   - add LIBDIR to the `LD_RUN_PATH' environment variable
     during linking
   - use the `-Wl,--rpath -Wl,LIBDIR' linker flag
   - have your system administrator add LIBDIR to `/etc/ld.so.conf'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and ld.so(8) manual pages.
----------------------------------------------------------------------
for FN in /home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src/expat-2.0.1/lib/expat.h /home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src/expat-2.0.1/lib/expat_external.h ; do /usr/bin/install -c -m 644 $FN /home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/build-native/host-libs/usr/include ; done
/bin/sh /home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src/expat-2.0.1/conftools/mkinstalldirs /home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/build-native/host-libs/usr/bin /home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/build-native/host-libs/usr/man/man1
mkdir /home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/build-native/host-libs/usr/man
mkdir /home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/build-native/host-libs/usr/man/man1
/bin/sh ./libtool --mode=install /usr/bin/install -c xmlwf/xmlwf /home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/build-native/host-libs/usr/bin/xmlwf
/usr/bin/install -c xmlwf/xmlwf /home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/build-native/host-libs/usr/bin/xmlwf
/usr/bin/install -c -m 644 /home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src/expat-2.0.1/doc/xmlwf.1 /home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/build-native/host-libs/usr/man/man1
~/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src
Task [II-0] /i686-w64-mingw32/zlib/
~/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/build-mingw/zlib ~/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/src
Compiler error reporting is too harsh for ./configure (perhaps remove -Werror).
** ./configure aborting.

Revision history for this message
yu (peace567) said :
#7

Hi,

I found more information on my error.
i686-w64-mingw32-gcc is not installed on my Ubuntu. i586-mingw32msvc-gcc is installed.
But I cannot find where is such command is defined. Could anyone help?
Thank you very much!
--------------------
./configure --static --prefix=/home/yu/toolchain/gcc-arm-none-eabi-5_4-2016q3-20160926/build-mingw/host-libs/zlib
Tue Feb 14 11:22:24 HKT 2017
=== ztest20298.c ===
extern int getchar();
int hello() {return getchar();}
===
i686-w64-mingw32-gcc -c ztest20298.c
./configure: line 165: i686-w64-mingw32-gcc: command not found
... using i686-w64-mingw32-gcc

Checking for obsessive-compulsive compiler options...
=== ztest20298.c ===
int foo() { return 0; }
===
i686-w64-mingw32-gcc -c -O ztest20298.c
./configure: line 343: i686-w64-mingw32-gcc: command not found
(exit code 127)
Compiler error reporting is too harsh for ./configure (perhaps remove -Werror).
** ./configure aborting.

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#8

Hi Yu,

i686-w64-mingw32-gcc should be installed if you follow the steps in the How to build document in section 1.2, in particular the first apt-get install line. I suggest you try again with the 2017Q1 release which has been noticeably improved with regards to the documentation.

Best regards.

Revision history for this message
yu (peace567) said :
#9

Hi Thomas,

I followed the steps in the doc How to build, but I didn't get i686-w64-mingw32-gcc. Here is the packages I can find:
yu@ubuntu:~$ sudo apt-cache search mingw
[sudo] password for yu:
mingw32 - Minimalist GNU win32 (cross) compiler
mingw32-binutils - Minimalist GNU win32 (cross) binutils
mingw32-runtime - Minimalist GNU win32 (cross) runtime

I have installed all these three packages. There is no package mingw64.
Could you please help me to install i686-w64-mingw32-gcc?
Thank you very much!

Best,
yu

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#10

Hi Yu,

The package that provides it is gcc-mingw-w64-i686. This package should be available if you added the i386 architecture as foreign (dpkg --add-architecture i386) and then updated the package database (apt-get update) as instructed in the manual.

Best regards.

Revision history for this message
yu (peace567) said :
#11

Hi Thomas,

Thanks very much for your help!
I cannot execute dpkg --add-architecture i386. And I have other problems after build package gcc-mingw-w64-i686.
I found i686-w64-mingw32-gcc is in prebuilt-native-tools.tar.lzma.
So I redo the build process and success in getting the windows tool chain.

Here I want to remind others who want to build the tool chain:
Please provide > 30G space for Ubuntu, as I have taken 18G to build it.
Otherwise, there will be "not enough space" error.

Best,
yu

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#12

Hi Yu,

What was the problem you encountered trying to add i386? What version of Ubuntu are you using?

Best regards.

Revision history for this message
yu (peace567) said :
#13

Hi Thomas,

The option is unknown. The Ubuntu I am using is ubuntu-8.10-desktop-i386.

yu@ubuntu:~$ dpkg --add-architecture i386
dpkg: unknown option --add-architecture

Type dpkg --help for help about installing and deinstalling packages [*];
Use `dselect' or `aptitude' for user-friendly package management;
Type dpkg -Dhelp for a list of dpkg debug flag values;
Type dpkg --force-help for a list of forcing options;
Type dpkg-deb --help for help about manipulating *.deb files;
Type dpkg --license for copyright license and lack of warranty (GNU GPL) [*].

Options marked [*] produce a lot of output - pipe it through `less' or `more' !

Best,
yu

Revision history for this message
Thomas Preud'homme (thomas-preudhomme) said :
#14

Hi Yu,

This error is because your Ubuntu version is too old. Our build instructions indicate Ubuntu 14.04 should be used.

Best regards.

Revision history for this message
yu (peace567) said :
#15

Hi Thomas,

Thanks for your information!

Have a good day!