无法安装rpi_ws281x"错误:命令' gcc'退出状态1"

时间:2015-02-07 09:21:35

标签: python c compiler-errors raspberry-pi linker-errors

我正在尝试在我的Raspberry Pi A +上安装Neopixels库。起初我做了这个,并试图运行代码,但它不起作用。我再次重新安装Raspbian并仔细安装了标头和库我得到了这个:

> 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

我看到了一些关于这个问题的问题:“安装libevent-dev”它没有用。

2 个答案:

答案 0 :(得分:7)

刚刚遇到这个问题,虽然这已经很久了,但我认为我会在这里找到那些偶然发现这个问题的人。如果你在这里,那么你可能正在做this。该问题的实际解决方案是您忘记在rpi_ws281x目录中运行命令“scons”,该目录将下载您需要的更多依赖项,包括OP所引用的缺少的ws2811库。意外地自己跳过了这一步:p。

答案 1 :(得分:4)

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

这是真正的错误。 collect2是编译阶段ld的包装脚本。 cannot find -lws2811表示无论您尝试编译什么,都会尝试链接libws2811,并且链接器无法找到该库来解析未定义的引用。

因此,无论您尝试做什么,都要尝试找出如何安装缺少的库。尝试从here下载库,并在尝试运行安装脚本之前将LD_LIBRARY_PATH设置为指向保存该文件的位置。