I am new in C, I am writing a Python C extension to improve speed.
here is my setup tool:
# file: setup.py
from distutils.core import setup, Extension
extra_objects = ["/Users/rrg/Documents/test/aliyun-log-c-
sdk/build/Debug/lib/liblog_c_sdk_static.a"]
module1 = Extension('pycproducer',
sources=['pycproducer.c'],
extra_objects=extra_objects)
setup(name='pycproducer',
version='1.0',
description='This is a Math package',
ext_modules=[module1])
But when I run python setup.py install
or python setup.py build
, it shows:
ld: warning: The i386 architecture is deprecated for macOS (remove from the Xcode build setting: ARCHS)
ld: warning: ignoring file
/Users/rrg/Documents/test/aliyun-log-c-sdk/build/Debug/lib/liblog_c_sdk_static.a, file was built for archive which is not the architecture being linked (i386): /Users/rrg/Documents/test/aliyun-log-c-sdk/build/Debug/lib/liblog_c_sdk_static.a
It also shows that the compile command is:
cc -bundle -undefined dynamic_lookup -arch x86_64 -arch i386 -Wl,-F. build/temp.macosx-10.13-intel-2.7/pycproducer.o /Users/rrg/Documents/test/aliyun-log-c-sdk/build/Debug/lib/liblog_c_sdk_static.a -o build/lib.macosx-10.13-intel-2.7/pycproducer.so
I guess the problem is that I use a static library: liblog_c_sdk_static.a
, but the library only support x64. However, when I run python setup.py install
, the compile command includes -arch x86_64 -arch i386
, which makes this issue.
So my problem is:
- How can I specify only X64 in my
setup.py
? I do not want to support i386. - or how can I remove
-arch i386
from the compile command? The compile command is automatically generated bydistutils
(I guess) when I runpython setup.py install