1

I would like to create a python C extension using XCode 4.5.2 so that I can use the xcode debugger. The extensions require the C file to be linked as a .so file. I have not been able to make .so file in xcode, only dylib files.

I tried as follows: 1. Used the C/C++ Library template, specified dynamic library 2. Change the Mach-O type to Bundle 3. Still could not make an .so so I changed the wrapper extension to .so, with no luck.

The post link below seems to say that I can just manually change the extension. This did not work for me, but I could have made another mistake.

how to make python load dylib on osx

Any thoughts on my problem?

Community
  • 1
  • 1
Chuck Carlson
  • 977
  • 8
  • 26
  • "The extensions require the C file to be linked as a .so file" - probably you were reading the Linux tutorial. `.so` files have the **very same purpose** on Linux that `.dylib`s on OS X. So don't even try to compile programs to a .so on OS X, let them be linked as .dylib normally, I'm sure Python (or the dynamic linker) will figure it out. If not, symlink `MyPyExtension.dylib` to `MyPyExtension.so` as a last hackish solution. –  Dec 31 '12 at 07:23
  • Thanks H2CO3, the hack of making the link from .so to the dylib worked. I was unable to replace the so with the dylib, so had to make the link instead. – Chuck Carlson Dec 31 '12 at 22:30
  • BTW, as a new user on stackoverflow, I don't see how to mark this question as answered or give credit to H2CO3. – Chuck Carlson Dec 31 '12 at 22:35

1 Answers1

1

.so files serve the same purpose on Linux (and some other Unixes) that .dylib files on OS X - they're dynamically linked libraries. If everything else fails, and Python cannot recognize your platform (and the fact that on OS X, it should look for .dylib files instead), make a symbolic link from the .dylib file with the same name but with the extension .so.

(Yes, this is a quite ugly hack, but it's simple, straightforward and it works.)