时间:2021-05-22
非 static 编译
不指定额外参数直接编译 Python:
$ ./configure$ make查看所依赖的共享库:
$ ldd python linux-vdso.so.1 => (0x00007fffcd95a000) libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007fab5c350000) libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007fab5c140000) libutil.so.1 => /lib/x86_64-linux-gnu/libutil.so.1 (0x00007fab5bf20000) libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007fab5bc10000) libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007fab5b840000) /lib64/ld-linux-x86-64.so.2 (0x00007fab5c600000)static 编译
指定 static 相关参数编译 Python:
$ ./configure LDFLAGS="-static" --disable-shared$ make LDFLAGS="-static" LINKFORSHARED=" "发现有部分库未能被编译,编译结果中输出如下内容:
Failed to build these modules:_bisect _bsddb _codecs_cn_codecs_hk _codecs_iso2022 _codecs_jp_codecs_kr _codecs_tw _collections_csv _ctypes _ctypes_test_curses _curses_panel _elementtree_functools _hashlib _heapq_hotshot _io _json_locale _lsprof _multibytecodec_multiprocessing _random _socket_sqlite3 _ssl _struct_testcapi _tkinter arrayaudioop binascii bz2cmath cPickle cryptcStringIO datetime dbmfcntl future_builtins gdbmgrp itertools linuxaudiodevmath mmap nisoperator ossaudiodev parserpyexpat readline resourceselect spwd stropsyslog termios timeunicodedata zlib查看所依赖的共享库:
$ ldd python not a dynamic executablestatic 编译相关 module
编辑 Modules/Setup.local 为:
# Edit this file for local setup changes*static*_bisect _bisectmodule.c# _bsddb _bsddb.c # 额外依赖PyBSDDB_codecs_cn cjkcodecs/_codecs_cn.c_codecs_hk cjkcodecs/_codecs_hk.c_codecs_iso2022 cjkcodecs/_codecs_iso2022.c_codecs_jp cjkcodecs/_codecs_jp.c_codecs_kr cjkcodecs/_codecs_kr.c_codecs_tw cjkcodecs/_codecs_tw.c_collections _collectionsmodule.c_csv _csv.c# _ctypes _ctypes/_ctypes.c _ctypes/callbacks.c _ctypes/callproc.c _ctypes/cfield.c _ctypes/malloc_closure.c _ctypes/stgdict.c # 还依赖Python源中的 libffi# _ctypes_test # 同_ctypes# _curses _cursesmodule.c # 额外依赖ncurses# _curses_panel _curses_panel.c # 额外依赖ncurses# _elementtree _elementtree.c expat/loadlibrary.c expat/xmlparse.c expat/xmlrole.c expat/xmltok.c expat/xmltok_impl.c expat/xmltok_ns.c # 依赖的libexpat可能编译出错_functools _functoolsmodule.c# _hashlib _hashopenssl.c # 额外依赖OpenSSL_heapq _heapqmodule.c_hotshot _hotshot.c_io _io/_iomodule.c _io/bufferedio.c _io/bytesio.c _io/fileio.c _io/iobase.c _io/stringio.c _io/textio.c_json _json.c_locale _localemodule.c_lsprof _lsprof.c rotatingtree.c_multibytecodec cjkcodecs/multibytecodec.c# _multiprocessing _multiprocessing/multiprocessing.c _multiprocessing/pipe_connection.c _multiprocessing/semaphore.c _multiprocessing/socket_connection.c _multiprocessing/win32_functions.c_multiprocessing _multiprocessing/multiprocessing.c _multiprocessing/socket_connection.c_random _randommodule.c_socket socketmodule.c# _sqlite3 _sqlite/cache.c _sqlite/connection.c _sqlite/cursor.c _sqlite/microprotocols.c _sqlite/module.c _sqlite/prepare_protocol.c _sqlite/row.c _sqlite/statement.c _sqlite/util.c # 额外依赖sqlite3 # _ssl _ssl.c 额外依赖OpenSSL_struct _struct.c_testcapi _testcapimodule.c# _tkinter _tkinter.c # 额外依赖Tcl/Tkarray arraymodule.caudioop audioop.cbinascii binascii.c# bz2 bz2module.c # 额外依赖bzlibcmath cmathmodule.ccPickle cPickle.c# crypt cryptmodule.c # 额外依赖OpenSSLcStringIO cStringIO.cdatetime datetimemodule.c# dbm dbmmodule.c # 额外依赖gdbmfcntl fcntlmodule.cfuture_builtins future_builtins.c# gdbm gdbmmodule.c # 额外依赖gdbmgrp grpmodule.citertools itertoolsmodule.clinuxaudiodev linuxaudiodev.cmath mathmodule.c _math.cmmap mmapmodule.c# nis nismodule.c # 依赖glibc/nisoperator operator.cossaudiodev ossaudiodev.cparser parsermodule.c# pyexpat pyexpat.c # 依赖的libexpat可能编译出错# readline readline.c # 依赖readlineresource resource.cselect selectmodule.cspwd spwdmodule.cstrop stropmodule.csyslog syslogmodule.ctermios termios.ctime timemodule.cunicodedata unicodedata.czlib zlibmodule.c zlib/adler32.c zlib/compress.c zlib/crc32.c zlib/deflate.c zlib/example.c zlib/gzclose.c zlib/gzlib.c zlib/gzread.c zlib/gzwrite.c zlib/infback.c zlib/inffast.c zlib/inflate.c zlib/inftrees.c zlib/minigzip.c zlib/trees.c zlib/uncompr.c zlib/zutil.c重新编译后能将部分 Modules 编译为 static 库,输出:
Failed to build these modules:_bsddb _ctypes _ctypes_test_curses _curses_panel _elementtree_hashlib _sqlite3 _ssl_tkinter bz2 cryptdbm gdbm nispyexpat readline查看所依赖的共享库:
$ ldd python not a dynamic executable参考:
https://wiki.python.org/moin/BuildStatically
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
前言从字节码看java中this隐式传参具体体现(和python中的self如出一辙,但是比python中藏得更深),也发现了static与非static方法的
相关阅读:JavaScript事件学习小结(五)js中事件类型之鼠标事件JavaScript事件学习小结(一)事件流javaScript事件学习小结(四)eve
相关阅读:JavaScript事件学习小结(五)js中事件类型之鼠标事件JavaScript事件学习小结(一)事件流javaScript事件学习小结(四)eve
相关阅读:JavaScript事件学习小结(五)js中事件类型之鼠标事件JavaScript事件学习小结(一)事件流javaScript事件学习小结(四)eve
相关阅读:JavaScript事件学习小结(五)js中事件类型之鼠标事件JavaScript事件学习小结(一)事件流javaScript事件学习小结(四)eve