我正在尝试使用下面的文档静态地从GitHub构建CPython3.6:
https://wiki.python.org/moin/BuildStatically
将* shared *更改为* static *
仅在模块/设置文件中取消注释模块“testcapimodule”:
_testcapi _testcapimodule.c #Python C API测试模块
并使用'make LINKFORSHARED =“”'
运行但是我遇到了错误:
gcc -pthread -Wno-unused-result -Wsign-compare -DNDEBUG -g -fwrapv -O3 -Wall -Wstrict-prototypes -std=c99 -Wextra -Wno-unused-result -Wno-unused-parameter -Wno-missing-field-initializers -I. -I./Include -DPy_BUILD_CORE -c ./Modules/_testcapimodule.c -o Modules/_testcapimodule.o
./Modules/_testcapimodule.c: In function ‘test_datetime_capi’:
./Modules/_testcapimodule.c:2191:9: error: ‘PyDateTimeAPI’ undeclared (first use in this function)
if (PyDateTimeAPI) {
^
./Modules/_testcapimodule.c:2191:9: note: each undeclared identifier is reported only once for each function it appears in
./Modules/_testcapimodule.c:2203:5: error: ‘PyDateTime_IMPORT’ undeclared (first use in this function)
PyDateTime_IMPORT;
^
./Modules/_testcapimodule.c:2208:1: warning: control reaches end of non-void function [-Wreturn-type]
}
^
make: *** [Modules/_testcapimodule.o] Error 1
但是当我使用“ shared ”构建Cpython3.6时,它可以成功。