Error trying to build a C++ module that uses the standard c++ library

Discussion about programs, libraries and tools that work with MicroPython. Mostly these are provided by a third party.
Target audience: All users and developers of MicroPython.
Post Reply
User avatar
saiftyfirst
Posts: 12
Joined: Wed Mar 04, 2020 4:58 pm

Error trying to build a C++ module that uses the standard c++ library

Post by saiftyfirst » Fri Mar 20, 2020 2:12 pm

Hello, I am trying to add a user module written in C++ on the stm32 port. I have compiled the shared library with appropriate flags and written part of my python wrapper. The module micropython.mk looks like this:

EXAMPLE_MOD_DIR := $(USERMOD_DIR)
SRC_USERMOD += $(EXAMPLE_MOD_DIR)/test.c
LDFLAGS_USERMOD += $(EXAMPLE_MOD_DIR)/libupybotan.a /usr/arm-none-eabi/lib/libstdc++.a

However, when I try to build the firmware, I get the following error:
arm-none-eabi-ld: error: build-PYBV11/firmware.elf uses VFP register arguments, /usr/arm-none-eabi/lib/libstdc++.a(chrono.o) does not

I have seen this for modules I have compiled myself and was able to fix that. This time though I am bit confused on how to approach this since the libstdc++.a was simply downloaded with the GNU Arm Embedded toolchain.

Some help would be very appreciated :)

arm-none-eabi-gcc -dumpversion: 9.2.1

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

Re: Error trying to build a C++ module that uses the standard c++ library

Post by jimmo » Fri Mar 20, 2020 11:51 pm

It's because the compiler's libstdc++ is compiled with different floating point support to MicroPython.

On pybv11 we use -mfloat-abi=hard (i.e. VFP register arguments)

User avatar
saiftyfirst
Posts: 12
Joined: Wed Mar 04, 2020 4:58 pm

Re: Error trying to build a C++ module that uses the standard c++ library

Post by saiftyfirst » Sat Mar 21, 2020 10:12 pm

What I understand is that there is no way I can use it ?

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

Re: Error trying to build a C++ module that uses the standard c++ library

Post by jimmo » Sun Mar 22, 2020 3:22 am

saiftyfirst wrote:
Sat Mar 21, 2020 10:12 pm
What I understand is that there is no way I can use it ?
You could try building micropython with -mfloat-abi=soft? I'm not sure which ABI exactly the C++ stdlib uses, but some trial and error you may be able to find an option that matches.

User avatar
saiftyfirst
Posts: 12
Joined: Wed Mar 04, 2020 4:58 pm

Re: Error trying to build a C++ module that uses the standard c++ library

Post by saiftyfirst » Tue Mar 24, 2020 10:20 pm

Building everything with -mfloat-abi=softfp seems to have worked

Post Reply