Page 1 of 1

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

Posted: Tue May 11, 2021 8:59 am
by rckdev
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?

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

Posted: Tue May 11, 2021 11:46 am
by SpotlightKid
Did you set MPY_DIR in the Makefile?

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

Posted: Tue May 11, 2021 12:11 pm
by rckdev
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?