简体   繁体   English

libpython2.7.a缺少许多参考

[英]libpython2.7.a missing many references

I'm trying to compile a cython module with -static , but I am getting a lot of errors about missing references in libpython2.7.a . 我正在尝试使用-static编译一个cython模块,但是由于libpython2.7.a缺少引用,我遇到了很多错误。 For example: 例如:

    /usr/lib/x86_64-linux-gnu/libpython2.7.a(complexobject.o): In function `_Py_c_pow':
    (.text.unlikely+0x507): undefined reference to `pow'

I already have the package build-essential installed, which is one solution I found on Google. 我已经安装了build-essential软件包,这是我在Google上找到的一种解决方案。

My work flow is: 我的工作流程是:

cython --embed hi.py
gcc hi.c -lpython2.7 -I /usr/include/python2.7 -static

What am I missing to be able to link this file statically? 我无法静态链接此文件吗?

EDIT: Added additional linker options gcc hi.c -lpython2.7 -lm -pthread -lzlib -I /usr/include/python2.7 -static 编辑:添加了其他链接器选项gcc hi.c -lpython2.7 -lm -pthread -lzlib -I /usr/include/python2.7 -static

All the references to undefined functions went away, but ld is saying it can't find lzlib so compilation still fails. 所有对未定义函数的引用都消失了,但是ld表示找不到lzlib,因此编译仍然失败。 Without -lzlib I still get some undefined references. 没有-lzlib我仍然会得到一些未定义的引用。

As your package manager will show you, the library for zlib is libz.so , hence you must pass -lz . 正如您的软件包管理器将向您展示的那样,zlib的库是libz.so ,因此您必须传递-lz

Added by question owner: For other's reference all the linker options needed -lpython2.7 -lm -ldl -lutil -lz -pthread 由问题所有者添加:供其他参考,所有需要的链接器选项-lpython2.7 -lm -ldl -lutil -lz -pthread

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM