Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Undefined reference error using PlatformIO as IDE #52

Open
timothy3001 opened this issue Aug 28, 2017 · 1 comment
Open

Undefined reference error using PlatformIO as IDE #52

timothy3001 opened this issue Aug 28, 2017 · 1 comment
Labels

Comments

@timothy3001
Copy link

timothy3001 commented Aug 28, 2017

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 to ws2812_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
Copy link
Author

timothy3001 commented Aug 30, 2017

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants