jgarff / rpi_ws281x

Userspace Raspberry Pi PWM library for WS281X LEDs
BSD 2-Clause "Simplified" License
1.78k stars 622 forks source link

undefined reference to `pow' as of #409 #424

Closed TwiN closed 3 years ago

TwiN commented 3 years ago

As of https://github.com/jgarff/rpi_ws281x/pull/409, I am getting the following error when calling rpi_ws281x after installing it via scons:

# github.com/rpi-ws281x/rpi-ws281x-go
/usr/bin/ld: //usr/local/lib/libws2811.a(ws2811.o): in function `ws2811_set_custom_gamma_factor':
/home/pi/workspace/rpi_ws281x/ws2811.c:1298: undefined reference to `pow'
collect2: error: ld returned 1 exit status

I'm aware that I'm using this library through another repository, but I believe that the root cause lies within this repository (or more precisely, since the aforementioned PR (#409)).

I've created an issue on that library as well for traceability: https://github.com/rpi-ws281x/rpi-ws281x-go/issues/12

Xartrick commented 3 years ago

Seems that libm (lib math) isn't correctly linked to your project.

TwiN commented 3 years ago

You were right

Thank you @Xartrick

Silberlachs commented 3 years ago

I have exactly this issue. would be nice to have a tipp of actually linking it against clibm instead of just pointing out the obvious. I'm just calling "go get [link_to_repository]" , i can't see any way of passing linker flags here

DeepLightLabs commented 3 years ago

Could someone elaborate on the solution of linking libm? I am encountering the same error here. Not sure how to reference this lib to correctly link. Thanks! @Xartrick

KC5-BP commented 2 years ago

Hi there ^^

Link libm or the math lib. to the cmd as follow : $ gcc main.c -lws2811 -lm -o \<yourOutputName> Also find the ref. here https://stackoverflow.com/questions/5419366/why-do-i-have-to-explicitly-link-with-libm

Edit: The \<> didn't displayed if they're not precede by \

Didn't notice at post, sorry ^^'

nmerchant commented 2 years ago

Hi there ^^

Link libm or the math lib. to the cmd as follow : $ gcc main.c -lws2811 -lm -o Also find the ref. here https://stackoverflow.com/questions/5419366/why-do-i-have-to-explicitly-link-with-libm

Thanks so much for the reply! Running that command returns:

gcc: error: missing filename after ‘-o’

Any idea what should go after -o?

TwiN commented 2 years ago

@nmerchant after -o, you can specify the name of the output binary. For instance, if you want the output binary to be baguette, you'd do -o baguette.