portmodules.h: No such file or directory

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
ttmetro
Posts: 104
Joined: Mon Jul 31, 2017 12:44 am

portmodules.h: No such file or directory

Post by ttmetro » Sat Dec 16, 2017 12:48 am

I'm following the tutorial for adding modules (http://micropython-dev-docs.readthedocs ... odule.html) and am trying to add "mymodule" to the standard esp32 port (the new rebased one).

Compilation fails with portmodules.h: No such file or directory:

Code: Select all

make
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
GEN build/genhdr/qstr.i.last
mymodule.c:5:25: fatal error: portmodules.h: No such file or directory
compilation terminated.
make: *** [build/genhdr/qstr.i.last] Error 1
make: *** Deleting file `build/genhdr/qstr.i.last'
Uncommenting portmodules.h leads to an error later in the compilation process:

Code: Select all

CC ../../py/objmodule.c
In file included from ../../py/mpconfig.h:45:0,
                 from ../../py/obj.h:29,
                 from ../../py/objmodule.h:29,
                 from ../../py/objmodule.c:30:
./mpconfigport.h:182:50: error: 'mp_module_mymodule' undeclared here (not in a function)
  { MP_OBJ_NEW_QSTR(MP_QSTR_mymodule), (mp_obj_t)&mp_module_mymodule }, \
                                                  ^
../../py/objmodule.c:225:5: note: in expansion of macro 'MICROPY_PORT_BUILTIN_MODULES'
     MICROPY_PORT_BUILTIN_MODULES
     ^
make: *** [build/py/objmodule.o] Error 1
Suggestions most welcome!
Bernhard Boser

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

Re: portmodules.h: No such file or directory

Post by SpotlightKid » Sat Dec 16, 2017 4:13 pm

Well, obviously, the header that declares your mp_module_mymodule hasn't been included. Did you add it (or the .c file) to the appropriate places in the Makefile?

2ni
Posts: 1
Joined: Thu Feb 01, 2018 9:40 am

Re: portmodules.h: No such file or directory

Post by 2ni » Thu Feb 01, 2018 9:42 am

You probably forgot to add the following line in mpconfigport.h as stated in the doc (http://micropython-dev-docs.readthedocs ... odule.html):
extern const struct _mp_obj_module_t mp_module_mymodule;

bskp
Posts: 2
Joined: Sun Sep 22, 2019 2:27 pm

Re: portmodules.h: No such file or directory

Post by bskp » Sun Sep 22, 2019 2:30 pm

Hi 2ni. I just created a forum account to thank you – stupid me committed exactly this crime!

Post Reply