MicroPython mising headers when trying to compile C code into mpy files

The official pyboard running MicroPython.
This is the reference design and main target board for MicroPython.
You can buy one at the store.
Target audience: Users with a pyboard.
Post Reply
rckdev
Posts: 7
Joined: Fri Apr 30, 2021 10:38 am
Contact:

MicroPython mising headers when trying to compile C code into mpy files

Post by rckdev » Tue May 11, 2021 8:59 am

Hi,
I'm following this documentation to compile a C library of mine into .mpy files so that i can use it as an external python module in my code.
For testing purpose I've created a "test.c" source file, containing the "test" function.
The first line is

Code: Select all

#include "py/dynruntime.h"
as required by the documentation.
I've written a Makefile following the instuctions in the example (giving it the correct mycropython path, the arch (armv7emsp for an stm32 machine) and including the py/dynruntime.mk).

The build procedure stops after creating a "build" directory with "test.config.h" inside and give me this error:

Code: Select all

Compilation started at Tue May 11 09:23:20

make -k 
CC test.c
In file included from ../../../micropython/py/nativeglue.h:30,
                 from ../../../micropython/py/dynruntime.h:32,
                 from test.c:1:
../../../micropython/py/obj.h:29:10: fatal error: assert.h: No such file or directory
   29 | #include <assert.h>
      |          ^~~~~~~~~~
compilation terminated.
make: *** [../../../micropython/py/dynruntime.mk:130: build/test.o] Errore 1
make: L'obiettivo «all» non è stato rigenerato a causa di errori.

Compilation exited abnormally with code 2 at Tue May 11 09:23:20
Why can't MicroPython find its own header? Am I forgetting something about the process?

SpotlightKid
Posts: 463
Joined: Wed Apr 08, 2015 5:19 am

Re: MicroPython mising headers when trying to compile C code into mpy files

Post by SpotlightKid » Tue May 11, 2021 11:46 am

Did you set MPY_DIR in the Makefile?

rckdev
Posts: 7
Joined: Fri Apr 30, 2021 10:38 am
Contact:

Re: MicroPython mising headers when trying to compile C code into mpy files

Post by rckdev » Tue May 11, 2021 12:11 pm

SpotlightKid wrote:
Tue May 11, 2021 11:46 am
Did you set MPY_DIR in the Makefile?
Yes, and I know it's properly set because the compiler is able to reach the py/dynruntime.h header.
The problem is the "py/obj.h" file which cannot locate the "assert.h" header.
This is the result of a search of "assert.h" inside the Micropython folder. None of these files is the one the obj.h is looking for. What header doest it want?

Post Reply