Open R3tr0BoiDX opened 2 years ago
The header file "declares" all the functions you're using, but the object file or library is responsible for "defining" them.
You need to add -lws2811
to instruct gcc to link against the ws2812 library and include the definitions of ws2811_fini
. In the simplest sense this either smooshes your code and the library code together into a single executable (static linking) or allows gcc to create a binary that knows where to find the library file dynamic linking).
So:
gcc main.c -lws2811 -o test
Hello LED pals ;)
In advance, if you encounter that issue after linking the -lws2811 ('cause I did) :
$ gcc main.c -lws2811 -o test
/usr/bin/ld: /usr/local/lib/libws2811.a(ws2811.c.o): in function ws2811_set_custom_gamma_factor:
ws2811.c:(.text+0x2934): undefined reference to pow
collect2: error: ld returned 1 exit status
Just link the math lib. into the cmd as follow : $ gcc main.c -lws2811 -lm -o test
I did installed the library as described in the README by doing
However, if I want to compile my code with
gcc main.c -o test
, I getmain.c:(.text+0x18): undefined reference to 'ws2811_fini'
for example.My
main.c
:#include <ws2811/ws2811.h> int main(int argc, char const *argv[]) { return 0; }