views:

49

answers:

2

Hi guys,

I want to use Python-MySQLDB library on Mac so I have compiled the source code to get the _mysql.so under Mac10.5 with my Intel iMac (i386)

This _mysql.co works in 2 of my iMacs and another Macbook. But that's it, it doesn't work in any other Macs.

Does this mean some machine specific info got compiled into the file?

+1  A: 

If you've only built one architecture (i386 / PPC) then it won't work on Macs with the opposite architecture. Are the machines that don't work PPC machines, by any chance?

Sometimes build configurations are set up to build only the current architecture by default - I haven't build Python-MySQLDB so I'm not sure if this is the case here, but it's worth checking.

You can find out which architectures have been built with the 'file' command in Terminal.

(Incidentally do you mean ".so"? I'm not familiar with ".co" files.)

jlarcombe
+1  A: 

Perform a file check against the _mysql.so file:

% file _mysql.so
_mysql.so: Mach-O 64-bit bundle x86_64

Make sure that it is compiled for the right architecture on the Macs on which it is not working. If you are trying to use it on any PowerPC (PPC) Macs, you will need to re-compile MySQLDB as a Universal binary.

For example, a Universal binary (such as the pre-installed version of Python) would look like this:

% file /usr/bin/python
/usr/bin/python: Mach-O universal binary with 3 architectures
/usr/bin/python (for architecture x86_64):      Mach-O 64-bit executable x86_64
/usr/bin/python (for architecture i386):        Mach-O executable i386
/usr/bin/python (for architecture ppc7400):     Mach-O executable ppc

So to answer your question: Yes, it seems like you might have compiled the module without Universal support, however I can't answer this definitively without more information.

jathanism
The _mysql.so I compiled is just for i386. And those iMacs which has problem are also i386 architecture.
Yinan
Ok! So other than just not working, what errors are you receiving when you try to import the module?
jathanism