简体   繁体   中英

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

I want to use C++ functions in Python program, so I compiled the dynamic library file with the command:

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

But when I used it in python file, I got this error:

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)

I found mach-o file, but is an incompatible architecture (have 'arm64', need 'x86_64') , how can I fix it?

I found this:

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

By installing python for amd64, I solved this problem.@Alan Birtles Thank you very much.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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