繁体   English   中英

mach-o 文件,但它是一个不兼容的架构(有“arm64”,需要“x86_64”)

[英]mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')

我想在 Python 程序中使用 C++ 函数,所以我用命令编译了动态库文件:

cc -fPIC -shared -o encrypt_for_python.so encrypt_for_python.cpp -L/opt/homebrew/Cellar/openssl@1.1/1.1.1l/lib -I/opt/homebrew/Cellar/openssl@1.1/1.1.1l/include -lssl -lcrypto -std=c++11

但是当我在 python 文件中使用它时,我得到了这个错误:

Traceback (most recent call last):
  File "/Users/debris/Documents/Job/HA/encryption-cpp/test_encrypt.py", line 6, in <module>
    my_func = CDLL(so_file)
  File "/Users/debris/miniconda3/lib/python3.9/ctypes/__init__.py", line 382, in __init__
    self._handle = _dlopen(self._name, mode)
OSError: dlopen(/Users/debris/Documents/Job/HA/encryption-cpp/encrypt_for_python.so, 0x0006): tried: '/Users/debris/Documents/Job/HA/encryption-cpp/encrypt_for_python.so' (mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64')), '/usr/local/lib/encrypt_for_python.so' (no such file), '/usr/lib/encrypt_for_python.so' (no such file)

我找到了mach-o 文件,但它是一个不兼容的架构(有 'arm64',需要 'x86_64') ,我该如何修复它?

我找到了这个:

file ~/miniconda3/bin/python
/Users/debris/miniconda3/bin/python: Mach-O 64-bit executable x86_64

通过为 amd64 安装 python,我解决了这个问题。@Alan Birtles 非常感谢。

暂无
暂无

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

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