My user defined library is not getting linked, the src files are not being linked with their headers. If you need the repository just ask for it. These is the linking error:
Linking .pio/build/nanorp2040connect/firmware.elf
/Users/francesco/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld: .pio/build/nanorp2040connect/src/main.cc.o: in function neopixel_led::palette_crgb::CrgbPalette16::CrgbPalette16(neopixel_led::Crgb const&)': /Users/francesco/Projects/IOT-Led_Lamp/lib/include/palette_crgb.h:33: undefined reference to neopixel_led::uitl_crgb::FillCrgbArray(neopixel_led::Crgb*, unsigned short, neopixel_led::Crgb const&)’
/Users/francesco/.platformio/packages/toolchain-gccarmnoneeabi/bin/…/lib/gcc/arm-none-eabi/9.2.1/…/…/…/…/arm-none-eabi/bin/ld: .pio/build/nanorp2040connect/src/main.cc.o: in function __static_initialization_and_destruction_0(int, int)': /Users/francesco/Projects/IOT-Led_Lamp/src/main.cc:7: undefined reference to neopixel_led::palette_crgb::ColorFromPalette(neopixel_led::palette_crgb::CrgbPalette16 const&, unsigned char, unsigned char, neopixel_led::palette_crgb::BlendType)’
collect2: error: ld returned 1 exit status
*** [.pio/build/nanorp2040connect/firmware.elf] Error 1
I just can’t understand how to use user defined library.
In order to understand better the problem i’ve tried to build a test app:
This is the directory:
My hypotesis is that i am doing something wrong withe the library structure because after studing the platformIO documentation about user-defined library i could not find anything about multiple files. In anycase this is the directory:
This is not the right folder structure at all. The README of the lib/ folder says you need to create a new library folder in lib/, for example, lib/MyGreateLibrary/<src/, include/>.
That folder structure does look good now. Can you show / upload the exact code for them?
For future reference, that error message is not the one you’d want to show because it says the least. It just says “linking error :(”. The lines above that error are the critcial details on what exactly is wrong.
After I move the files in lib/ into a new folder in the same way shown above and move a function call that was attempted in a global scope rather than inside a functino, it compiles with 0 errors for me.