cpldcpu / light_ws2812

Light weight library to control WS2811/WS2812 based LEDS and LED Strings for 8-Bit AVR microcontrollers.
GNU General Public License v3.0
946 stars 207 forks source link

Undefined reference error using PlatformIO as IDE #52

Open timothy3001 opened 7 years ago

timothy3001 commented 7 years ago

Hello guys,

this problem occured due to my little knowledge about compiler and linker stuff and how everything works together I guess, but I'm getting the following error whenever I'm trying to build the Blinky example in platformio: ccWcx3C7.ltrans0.o:(.text.startup+0x66): undefined reference tows2812_setleds(cRGB*, unsigned int)'`

As IDE I'm using platformio and I have absolutely no idea why I get this error. The header files of light_ws2812.h are found obviously, because there'd be a file not found error. I cannot find the reason for that undefined reference error, maybe you can guide me into the right direction.

As I said, I'm not an compiler / linker expert and can't really give you much information about my setup because i don't know how. But the config files of platformio tell me something about atmelavr and as a board I'm using ATTiny13.

Hopefully you can provide me with some information on how to investigate further. Unfortunately this really is all I'm getting right now. Maybe you do know some gcc parameters or something? I'd try to figure out how to set them in platformio

Thanks in advance Timo

timothy3001 commented 7 years ago

Ok, after some more research I've found, that the function "ws2812_setleds" is defined as an inline function in the light_ws2812.c file and was declared in the header file light_ws2812.h.

As I said, I'm no expert, especially not in C and C++ but when I googled inline functions I've found that they must be defined in the header files, as you can read here: https://stackoverflow.com/questions/4769479/c-inlining-class-methods-causes-undefined-reference

Anyways, not sure if it's a problem that should be fixed or not, I ended up putting the inline functions into the header file and it worked. One thing for platformio though: you might have to change the filename of light_ws2812.c to .cpp.

I leave this open, in case this actually is a problem and you want to fix it. If not, feel free to close it.