I have a library which was originally written for Arduino UNO board. I am trying to wrap up a part of C++ code from this library using pybind11 module. The requirement of this pybind11 is to have C++11 compatible compiler (as mentioned in “pybind11 documentation”). I tried compiling this library using Platformio in VSCode and it was successful. Now when I add pybind11 library, it throws include errors even after the path being added to both c_cpp_properties.json as well as tasks.json.
Has anyone tried anything similar previously and was successful?
Also can someone please explain what and how the compiler is invoked in Platformio in VSCode?
Thanks for your valuable inputs!
Yes I do understand that JSON files are autogenerated. But like I mentioned since I was running into include errors the red squizzly lines on the headers suggested the path to be added to include path and I so did that.
Coming to the second part, pybind11 is a header only library that has dependency on python and C++ libraries. And I tried adding a new folder in lib/ and dumped the pybind11 into it and created a library.json. With this the dependent files are not getting included (Like: <Python.h>).
Sorry, I am trying my hands on Platformio for the first time and hence the lack of knowledge. Could you please guide me here with further steps?
Hey Max! Yes I do understand the fact that a python core cannot fit into an Arduino UNO . I think I have not put it correctly. Let me re-iterate my use case.
I have a sensor library written in C++ which was developed for Arduino UNO board initially.
Now I am trying to make the library platform agnostic so that I can use this library on other hardware platforms like RaspberryPi which means a single core library running on different platforms.
In order to do so, I want to extend existing C++ code (part of library that will not use any arduino specific functions) by wrapping them using pybind11 and import this module to python and for the arduino specific functions python modules will be called by embedding the python interpreter.
Now to create these bindings I need to run the code at least once as is and hence the need of platformio (though it wont be actually flashed into aduino uno board).
So you see its just the case of getting the code compiled so that the wrappers are generated and can be used in python. It wont be flashed into Arduino board.
Hope this explanation clears the use case of why I need pybind11 in platformio.
Thank you for your time and inputs! I would like to know if you have any thoughts on this further. Meanwhile, I would also check if micropython can be applicable in this case!
hope that the comppiler is able to emit code for what will be a very large binary… it may be that due to the 8-bit AVR nature, it has a 16-bit adddress space resulting in only being able to compile a maximum of 64kByte of code.