2

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:

  1. How can I specify only X64 in my setup.py? I do not want to support i386.
  2. or how can I remove -arch i386 from the compile command? The compile command is automatically generated by distutils(I guess) when I run python setup.py install
ruiruige1991
  • 615
  • 1
  • 10
  • 21
  • Finally I did not solve the problem, but I avoid it. I just write code on my MacBook, and compile it on a linux vm. – ruiruige1991 Feb 10 '19 at 05:15

0 Answers0