Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't install rpi_ws281x "error: command 'gcc' failed with exit status 1"

I'm trying to install the Neopixels library on my Raspberry Pi A+. at first I did this, and tried to run the code, but it doesn't work. I reinstalled Raspbian again and carefully installed the headers and the library I get this:

> Downloading https://pypi.python.org/…/s…/s/setuptools/setuptools-5.7.zip
Extracting in /tmp/tmpkD2xEW
Now working in /tmp/tmpkD2xEW/setuptools-5.7
Building a Setuptools egg in /home/pi/rpi_ws281x/python
/home/pi/rpi_ws281x/python/setuptools-5.7-py2.7.egg
running install
running bdist_egg
running egg_info
creating rpi_ws281x.egg-info
writing rpi_ws281x.egg-info/PKG-INFO
writing top-level names to rpi_ws281x.egg-info/top_level.txt
writing dependency_links to rpi_ws281x.egg-info/dependency_links.txt
writing manifest file 'rpi_ws281x.egg-info/SOURCES.txt'
reading manifest file 'rpi_ws281x.egg-info/SOURCES.txt'
writing manifest file 'rpi_ws281x.egg-info/SOURCES.txt'
installing library code to build/bdist.linux-armv6l/egg
running install_lib
running build_py
creating build
creating build/lib.linux-armv6l-2.7
copying neopixel.py -> build/lib.linux-armv6l-2.7
running build_ext
building '_rpi_ws281x' extension
swigging rpi_ws281x.i to rpi_ws281x_wrap.c
swig -python -o rpi_ws281x_wrap.c rpi_ws281x.i
creating build/temp.linux-armv6l-2.7
gcc -pthread -fno-strict-aliasing -DNDEBUG -g -fwrapv -O2 -Wall -Wstrict-prototypes -fPIC -I/usr/include/python2.7 -c rpi_ws281x_wrap.c -o build/temp.linux-armv6l-2.7/rpi_ws281x_wrap.o
rpi_ws281x_wrap.c: In function ‘init_rpi_ws281x’:
rpi_ws281x_wrap.c:4638:21: warning: variable ‘md’ set but not used [-Wunused-but-set-variable]
gcc -pthread -shared -Wl,-O1 -Wl,-Bsymbolic-functions -Wl,-z,relro build/temp.linux-armv6l-2.7/rpi_ws281x_wrap.o -L../. -lws2811 -o build/lib.linux-armv6l-2.7/_rpi_ws281x.so
/usr/bin/ld: cannot find -lws2811
collect2: ld returned 1 exit status
error: command 'gcc' failed with exit status 1

I saw some questions about this issue: "install libevent-dev" it didn't work.

like image 940
Wilty Avatar asked Dec 11 '22 01:12

Wilty


2 Answers

just came across this issue and even though this is old I thought I'd put the answer here for those who stumble upon this as well. Chances are if you are here then you are doing this. The actual solution to the problem is that you forgot to run the command "scons" in the rpi_ws281x directory, which will download more dependencies you need including the missing ws2811 library that OP is referring to. Accidentally skipped that step myself :p.

like image 181
Mattnv92 Avatar answered Dec 16 '22 12:12

Mattnv92


/usr/bin/ld: cannot find -lws2811
collect2: ld returned 1 exit status

This is the real error. collect2 is a wrapper script for ld during the compilation phase. cannot find -lws2811 means that whatever you are trying to compile tries to link against libws2811, and the linker fails to find that library to resolve the undefined references.

So, whatever it is you try to do, try to find out how to install the library missing. Try downloading the library from here, and set LD_LIBRARY_PATH to point to where you have saved that file before you try to run the installation script.

like image 31
NlightNFotis Avatar answered Dec 16 '22 10:12

NlightNFotis