Recently I had to migrate my project from Arduino to Visual Studio Code because the instructions to overcome Daisy’s flash limitations (see Creating a Bootloader via the Uart - #16 by shensley) are available only on VSC, as far as I know. I’m running VSC on Windows, and uploading through DFU, with no debug. I had no trouble running Blink and other simple examples. However I’m stuck trying to build my own library, to link it together with libDaisy. I’m a really newbie on VSC and I never had to understand or modify any makefile before. That’s the point. My approach was to mutatis mutandis from some existing library (libDaisy, in fact). Unfortunately this solution wasn’t effective, since I always got something wrong during compilation, like a missing “daisyseed.h” or an unidentified reference to some of my functions. As far as I understood, I have to configure not only the workspace makefile, but my library’s makefile too, and I’m certainly doing something weird, because nothing seems to work. Several weeks trying to find some useful example online or even some tutorial on how to configure makefile’s was a kind of frustrating, to say the less. So please, if someone could help me on how to create a simple library, I’d be very thankful.
It seems that you would benefit from learning some basics. Arduino hides lots of “complexity” under the hood. You are getting IDE, compiler, build system, flashing capabilities out of the box.
In “real” C++ development you’d select/setup all these pieces separately.
- VSC is just a code (actually text) editor, with ways to extend it to be full featured IDE. It has nothing to do with building your code.
- Makefile - is one of the build systems that are common in C++ dev. Cmake is another one (with bunch of features).
I’d recommend you dive into the DaisyExamples docs: https://github.com/electro-smith/DaisyExamples#adding-new-examples-and-updating-old-ones
Or, you can look how folks configured makefiles for their projects: https://github.com/MrBlueXav/Daikrispator
There’s only a few minor things that make static libraries special compared to making a normal binary:
main function is not present
- linking is done in a different way
Last point is about this command in Makefile:
$(BUILD_DIR)/$(TARGET).a: $(OBJECTS) Makefile
$(AR) rcs $@ $(OBJECTS)
Since you’ve already lookeded and DaisySP, you should be more specific about things that don’t work for you. As a starting point you could just use its copy with different TARGET/CPP_SOURCES variables.
Thank you guys. I tried to get my library working but I gave up soon I realized I didn’t get the required skills for that . Fortunately the hints from @brbrr about the Daikrispator just worked fine. I’m on track again.