原因
在 pyconfig 的 header file中,hypot 被重命名为了 _hypot 。而 cmath 调用了 hypot。
解决方法
解决方法有三种:
第一种方法: 在#include <Python.h>之前#include <math.h>。
#define PY_SSIZE_T_CLEAN
#include <math.h>
#include <Python.h>
第二种方法: 在编译选项里添加-D_hypot=hypot。
第三种方法: 修改Python.h头文件,在文件开头#include <math.h>。
#ifndef Py_PYTHON_H
#define Py_PYTHON_H
/* Since this is a "meta-include" file, no #ifdef __cplusplus / extern "C" { */
/* Include nearly all Python header files */
#include <math.h>
#include "patchlevel.h"
#include "pyconfig.h"
#include "pymacconfig.h"