Suggestions for porting library from Arduino

I’m trying to port a library from Arduino to Mongoose OS. In Arduino, this library works very well on the ESP32.

Admittedly, the Arduino IDE is very limited in what info about the build process it reveals, but this library compiles and runs well in the Arduino environment.

As I work to port it, I got many warnings and errors, and I’m trying to understand what compilers are used in each environment so I can see what the differences are. Also, I’m thinking that perhaps there are different compiler options used.

I would appreciate any information about the build differences and any suggestions, pro tips, and so on that others who have been through this process may be able to offer. Thanks very much.

1 Like

There is no general recipe to port a library from Arduino to Mongoose OS.
The warnings/errors can be solved by searching what they mean and fix them.
Have a look at this makefile if you want to know more about the way Mongoose OS builds the firmware.

That makefile is a great help thanks. I finally got my library ported. The library works on AVR, ESP devices and a few others. It also uses the Arduino SPI library. The library used two macros, __AVR__ and ARDUINO, as flags to trigger conditional compilation. So it was trying to use stuff like PROGMEM.

To solve it, I continued to specify the Arduino compatibility library in the ported librarie’s mos.yml file to get the SPI support, but I went through the rest of the code and used #undef to undefine the __AVR__ and ARDUINO where they were causing problems by causing non-ESP32 features like that PROGMEM to be used.

I’ll probably rewrite the code that uses SPI to use native Mongoose libraries, and then remove the Arduino compat library. But for anyone having similar problems, this is something you can check.