MacOS 和 Apple M1 芯片上的 CPython 问题
我最近将内容转移到一台运行 macOS Monterey 的新 Apple M1 笔记本电脑上,并且在尝试从 C++
调用 Python
函数的一段非常简单的代码方面遇到了一些问题。 此处提供了具体示例。
我通过 Homebrew
安装了新版本的 Python 3.9.10
,但我的编译器似乎没有检测到,因为我得到了以下信息错误:
surrutiaquir$ g++ -o main_ctp_fN_grid ctp_fN_grid.cpp -lgsl -lm -lgslcblas -std=c++11
Undefined symbols for architecture arm64:
"_PyDict_GetItemString", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyImport_Import", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyImport_ImportModule", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyList_Append", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyModule_GetDict", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyObject_CallObject", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyObject_GetAttrString", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyString_FromString", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_Py_Finalize", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_Py_Initialize", referenced from:
_main in ctp_fN_grid-2fc2a2.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
我对这个问题真的很困惑,所以任何指导将不胜感激。谢谢!
I recently moved my content to a new Apple M1 laptop running macOS Monterey and I have some problems with a very simple piece of code that tries to call a Python
function from C++
. A concrete example is available here.
I installed a new version of Python 3.9.10
via Homebrew
, but it seems it is not being detected by my compiler since I get the following errors:
surrutiaquir$ g++ -o main_ctp_fN_grid ctp_fN_grid.cpp -lgsl -lm -lgslcblas -std=c++11
Undefined symbols for architecture arm64:
"_PyDict_GetItemString", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyImport_Import", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyImport_ImportModule", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyList_Append", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyModule_GetDict", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyObject_CallObject", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyObject_GetAttrString", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_PyString_FromString", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_Py_Finalize", referenced from:
_main in ctp_fN_grid-2fc2a2.o
"_Py_Initialize", referenced from:
_main in ctp_fN_grid-2fc2a2.o
ld: symbol(s) not found for architecture arm64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
I'm really confused about this issue, so any guidance would be highly appreciated. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论