我从官方网站编译了 uwsgi 版本 x.y.zz.ww,我使用官方文档中建议的命令编译了 uwsgi
然后我使用官方文档中的命令编译了建议用于 Python 的插件,得到的错误输出是这样的:
>ubuntu@ip-xx-yy-zz-ww:~/tmp/uwsgi-xx.yy.zz.ww$ PYTHON=python3.4 ./uwsgi --build-plugin "plugins/python python34"
*** uWSGI building and linking plugin from plugins/python ***
[gcc -pthread] python34_plugin.so
/usr/bin/ld: /usr/local/lib/python3.4/config-3.4m/libpython3.4m.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
/usr/local/lib/python3.4/config-3.4m/libpython3.4m.a: error adding symbols: Bad value
collect2: error: ld returned 1 exit status
*** unable to build python34 plugin ***
使用 uwsgi 而不从源代码编译它的替代方法是使用 pip3 install uwsgi,在这种情况下,插件在文件夹 plugins/python/python_plugin.o 中编译但找不到它.我正在为项目使用 virtualenv,插件编译必须在 lib 文件夹中的根目录或 virtualenv 环境中?
最佳答案
老问题,但为了将来引用,这里是我所做的:
/usr/bin/ld: /usr/local/lib/python3.4/config-3.4m/libpython3.4m.a(abstract.o): relocation R_X86_64_32S against `_Py_NotImplementedStruct' can not be used when making a shared object; recompile with -fPIC
此行意味着您需要一个带有标志的 python 构建:-fPIC
,因此我卸载了 python 版本并在启用此标志的情况下重建。
像这样在构建之前导出标志:
export CFLAGS="$CFLAGS -fPIC"
或者,如果您正在使用 pyenv
env PYTHON_CFLAGS=-fPIC pyenv install 3.5.x
现在使用这个python,你可以编译一个python插件:
python uwsgiconfig.py --plugin plugins/python core python35
关于python - 为 Uwsgi 编译插件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/32587400/