Building from source - can't find stdio.h ! :-(

The official PYBD running MicroPython, and its accessories.
Target audience: Users with a PYBD
Post Reply
nherriot
Posts: 24
Joined: Wed Oct 19, 2016 1:02 pm

Building from source - can't find stdio.h ! :-(

Post by nherriot » Tue Jun 25, 2019 5:05 pm

Hi Micropython Folks,

OK - I'm trying to build from source and have even managed to add some help on the wiki https://github.com/micropython/micropyt ... ng-Started

However, I have a build problem on my main Linux Mint Release 18. I think it's an environment problem - but no idea 'how' to solve it!
When i try and compile for the pyboard 'D' with this command:

Code: Select all

make BOARD=PYBD_SF2 FROZEN_MPY_DIR=modules
The make scripts can't locate <stdlib.h>
This happens for every file that uses stdlib.h. I realise this is most likely something wrong with my environment. But some helpful pointers would be great. An example error message is:

Code: Select all

In file included from ../../lib/mbedtls/library/aes.c:31:0:
./mbedtls/mbedtls_config.h:83:20: fatal error: stdlib.h: No such file or directory
 #include <stdlib.h>
                    ^
compilation terminated.
In file included from ../../lib/mbedtls/library/aesni.c:30:0:
./mbedtls/mbedtls_config.h:83:20: fatal error: stdlib.h: No such file or directory
 #include <stdlib.h>
The libraries are definitely on my machine:

Code: Select all

~ $ find /usr/include/ -name "stdio.h"
/usr/include/x86_64-linux-gnu/bits/stdio.h
/usr/include/c++/4.7/tr1/stdio.h
/usr/include/c++/4.8/tr1/stdio.h
/usr/include/c++/5/tr1/stdio.h
/usr/include/stdio.h
/usr/include/i386-linux-gnu/bits/stdio.h
So it must be environment is wrong - but how do i fix or debug! Pulling my hair out!
My version of gcc is:

Code: Select all

gcc --version
gcc (Ubuntu 5.4.0-6ubuntu1~16.04.11) 5.4.0 20160609


Kind regards, Nicholas

User avatar
jimmo
Posts: 2754
Joined: Tue Aug 08, 2017 1:57 am
Location: Sydney, Australia
Contact:

Re: Building from source - can't find stdio.h ! :-(

Post by jimmo » Tue Jun 25, 2019 11:10 pm

You'll need to use the cross compiler arm-none-eabi-gcc

Can you try checking which version of that you have installed? (just run "arm-none-eabi-gcc -- version")

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Building from source - can't find stdio.h ! :-(

Post by dhylands » Tue Jun 25, 2019 11:31 pm

I suspect that you need to install libnewlib-arm-none-eabi (i.e. sudo apt install libnewlib-arm-none-eabi)

The fact that the make ran the compiler implies that arm-none-eabi-gcc is already being used, and that the C runtime library is being used.

I normally don't use the districution supplied toolchain and instead install the ARM one from here: https://developer.arm.com/tools-and-sof ... ain/gnu-rm which include the toolchain and the runtime libraries.

nherriot
Posts: 24
Joined: Wed Oct 19, 2016 1:02 pm

Re: Building from source - can't find stdio.h ! :-(

Post by nherriot » Wed Jun 26, 2019 9:48 am

jimmo wrote:
Tue Jun 25, 2019 11:10 pm
You'll need to use the cross compiler arm-none-eabi-gcc

Can you try checking which version of that you have installed? (just run "arm-none-eabi-gcc -- version")
Thanks for the help. :-) ... Yes i realised that this was missing from the instructions on the WiKi already and added them. But i had no idea that the version matters!

Well I have version 4.9

Code: Select all

nherriot@Zenbook-UX32A ~/virtalenv/microPython/project/micropython/ports/stm32 $ arm-none-eabi-gcc --version
arm-none-eabi-gcc (15:4.9.3+svn231177-1) 4.9.3 20150529 (prerelease)
Copyright (C) 2014 Free Software Foundation, Inc.
This is free software; see the source for copying conditions.  There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
I have a work machine which i can get to compile builds. However it's not ideal! :-( This is running Ubuntu 18LTS and arm-gcc version 6.3

Do i need to get a newer version on my work machine?

Kind regards, Nicholas

nherriot
Posts: 24
Joined: Wed Oct 19, 2016 1:02 pm

Re: Building from source - can't find stdio.h ! :-(

Post by nherriot » Wed Jun 26, 2019 1:41 pm

dhylands wrote:
Tue Jun 25, 2019 11:31 pm
I suspect that you need to install libnewlib-arm-none-eabi (i.e. sudo apt install libnewlib-arm-none-eabi)

The fact that the make ran the compiler implies that arm-none-eabi-gcc is already being used, and that the C runtime library is being used.

I normally don't use the districution supplied toolchain and instead install the ARM one from here: https://developer.arm.com/tools-and-sof ... ain/gnu-rm which include the toolchain and the runtime libraries.
Hi Dyhlands,

yip that did it! Thanks for the info. :-)

As you can probably guess, I was presented with errors from the arm tool chain after installing libnewlib-arm-none-eabi . I found people with similar issues and have since downloaded directly the arm tool chain and got it compiling! Fantastic!
Probably needs a dedicated well written section on this. I'll update the WiKi to let people know to check and install all the required packages.

From other forum posts I see this is an issue with Ubuntu 16 LTR. I'll add a note in the getting started section for 'Known Issues And Problems'. I used this https://developer.arm.com/tools-and-so ... downloads to download my ARM tool chain which I noticed is not the same URL - but it does seem to compile the builds!

Kind regards, Nicholas.

User avatar
dhylands
Posts: 3821
Joined: Mon Jan 06, 2014 6:08 pm
Location: Peachland, BC, Canada
Contact:

Re: Building from source - can't find stdio.h ! :-(

Post by dhylands » Wed Jun 26, 2019 2:13 pm

The readme does have a pointer to the arm toolchain in the STM32 section:
https://github.com/micropython/micropyt ... 32-version

nherriot
Posts: 24
Joined: Wed Oct 19, 2016 1:02 pm

Re: Building from source - can't find stdio.h ! :-(

Post by nherriot » Mon Jul 01, 2019 5:53 pm

dhylands wrote:
Wed Jun 26, 2019 2:13 pm
The readme does have a pointer to the arm toolchain in the STM32 section:
https://github.com/micropython/micropyt ... 32-version
Hi dhylands,

thanks for the pointer. :-)

I've created a specific page for people coming from a version of Ubuntu 16 or derivative which might help for them trying to fix issues with those systems. I'd be keen on feedback, the page is herehttps://github.com/micropython/micropyt ... ntu-16.04

Kind regards, Nicholas.

Post Reply