我正在尝试在必须在非标准位置安装libsnappy-dev的系统上安装this package,并且不知道如何在自动安装中包含正确的标志以帮助gcc找到开发文件。
可以预见,当我尝试使用
从github安装时pip git+git://github.com/andrix/python-snappy
我收到编译错误,因为无法找到.h文件(在非标准位置)。
Running setup.py install for python-snappy
building '_snappy' extension
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/app/.heroku/python/include/python2.7 -c snappymodule.cc -o build/temp.linux-x86_64-2.7/snappymodule.o
cc1plus: warning: command line option "-Wstrict-prototypes" is valid for Ada/C/ObjC but not for C++
snappymodule.cc:31:22: error: snappy-c.h: No such file or directory
snappymodule.cc:77: error: ‘snappy_status’ was not declared in this scope
snappymodule.cc:78: error: expected ‘,’ or ‘;’ before ‘{’ token
snappymodule.cc:45: warning: ‘_state’ defined but not used
snappymodule.cc:56: warning: ‘SnappyCompressError’ defined but not used
snappymodule.cc:57: warning: ‘SnappyUncompressError’ defined but not used
snappymodule.cc:58: warning: ‘SnappyInvalidCompressedInputError’ defined but not used
snappymodule.cc:59: warning: ‘SnappyCompressedLengthError’ defined but not used
snappymodule.cc:77: warning: ‘snappy_strerror’ defined but not used
error: command 'gcc' failed with exit status 1
Complete output from command /app/.heroku/python/bin/python -c "import setuptools, tokenize;__file__='/tmp/pip_build_u41994/python-snappy/setup.py';exec(compile(getattr(tokenize, 'open', open)(__file__).read().replace('\r\n', '\n'), __file__, 'exec'))" install --record /tmp/pip-3otpv5-record/install-record.txt --single-version-externally-managed --compile:
running install
我只是一个构建软件的黑客,但我想我需要像这样设置LDFLAGS变量:
export LDFLAGS="-L/app/vendor/snappy/usr/local/lib -L/app/vendor/snappy/usr/local/include"
但是,这并没有使其成为上面列出的gcc调用。有关如何解决此问题的任何想法?
编辑 :进度。分叉活泼和改变
snappymodule = Extension('_snappy',
libraries=['snappy'],
sources=['snappymodule.cc', 'crc32c.c'])
到
snappymodule = Extension('_snappy',
libraries=['snappy'],
sources=['snappymodule.cc', 'crc32c.c'],
extra_compile_args=['-L/app/vendor/snappy/usr/local/lib -L/app/vendor/snappy/usr/local/include',
'-I/app/vendor/snappy/usr/local/lib -I/app/vendor/snappy/usr/local/include'])
已将错误发展到
gcc -pthread -fno-strict-aliasing -g -O2 -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -fPIC -I/app/.heroku/python/include/python2.7 -c snappymodule.cc -o build/temp.linux-x86_64-2.7/snappymodule.o -L/app/vendor/snappy/usr/local/lib -L/app/vendor/snappy/usr/local/include -I/app/vendor/snappy/usr/local/lib -I/app/vendor/snappy/usr/local/include
意味着我们至少可以通过标志。仍然试图弄清楚正确的标志是什么。手动检查仍然确认snappy.h在附近。
~/vendor/snappy/usr/local/include $ pwd
/app/vendor/snappy/usr/local/include
~/vendor/snappy/usr/local/include $ ls
snappy-c.h snappy.h snappy-sinksource.h snappy-stubs-public.h