Can't load external C modules in MP Windows

C programming, build, interpreter/VM.
Target audience: MicroPython Developers.
Post Reply
ProudPagan
Posts: 35
Joined: Fri Apr 12, 2019 8:55 am

Can't load external C modules in MP Windows

Post by ProudPagan » Thu Jun 13, 2019 3:50 am

Hi,

I just created a C module that loads and works correctly on the unix port (WSL Ubuntu),
but when I create a windows exe and try to load it, I get:

Code: Select all

>>> import mpmymod
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
ImportError: no module named 'mpmymod'
I cross-compiled on WSL for Windows, and seems the C module source was picked up correctly, and I see the module directory
under build/

Code: Select all

$ make CROSS_COMPILE=i686-w64-mingw32-  USER_C_MODULES=. CFLAGS_EXTRA="-DMODULE_MPMYMOD_ENABLED=1"
Use make V=1 or set BUILD_VERBOSE in your environment to increase build verbosity.
Including User C Module from ./mpmymod
mkdir -p build/genhdr
GEN build/genhdr/mpversion.h
GEN build/genhdr/moduledefs.h
GEN build/genhdr/qstr.i.last
GEN build/genhdr/qstr.split
GEN build/genhdr/qstrdefs.collected.h
QSTR updated
....
LINK micropython.exe
   text    data     bss     dec     hex filename
 312240    3644    8732  324616   4f408 micropython.exe
I had a similar problem with frozen modules earlier that turned out to be missing path name in sys.path, so I checked that:

Code: Select all

>>> import sys
>>> print (sys.path)
['', 'C:/Users/pp/.micropython/lib:/usr/lib/micropython']
I see the null path at the beginning, so sys.path is alright.

Thanks!

PP

stijn
Posts: 735
Joined: Thu Apr 24, 2014 9:13 am

Re: Can't load external C modules in MP Windows

Post by stijn » Thu Jun 13, 2019 3:00 pm

You cross-compiled the windows port then, right? C modules for it hasn't been implemented completely, only the bare minimum to make it build.

ProudPagan
Posts: 35
Joined: Fri Apr 12, 2019 8:55 am

Re: Can't load external C modules in MP Windows

Post by ProudPagan » Fri Jun 14, 2019 6:37 am

I see. I'll stick to MP on WSL Ubuntu for now. Thanks.

Post Reply