tags:

views:

30

answers:

1

I am compiling a program that embeds Python, in particular Python v3.1. On my system I have several versions of the Python framework: 3.1, 2.5, 2.6. When I pass "-framework Python" to g++ when compiling, g++ seems to pull in version 2.6 (lives at "/System/Library/Frameworks/") instead of version 3.1 (lives at "/Library/Frameworks/"), resulting in an error. Both paths are in the framework search path, as is evident from attempting the same compilation in verbose mode (passing in -v to g++).

Although this would seem to be a simple thing, I have not been able to find mention of it in any documentation about g++, ld or xcode. Currently, I accomplish successful compilation by moving /System/Library/Frameworks/Python.framework to /System/Library/Frameworks/Python.framework.moved, but this is un ugly, temporary solution.

So, does anyone know what the best way of resolving this issue? In particular, I would like to be able to compile this program against the correct version of the Python framework, regardless of any other versions installed on the system.

Thanks.

A: 

Try first changing the Current symlink in the Python framework in /Library/Frameworks:

$ cd /Library/Frameworks/Python.framework/Versions
$ ls -l
total 4
drwxrwxr-x  8 root  admin  340 Aug 31 02:10 2.6/
drwxrwxr-x  8 root  admin  340 Oct  6 21:56 2.7/
drwxrwxr-x  7 root  admin  306 Oct  6 14:00 3.1/
lrwxr-xr-x  1 root  admin    3 Oct  7 00:33 Current@ -> 2.7
$ sudo rm Current
$ sudo ln -s 3.1 Current

(UPDATE) I was hoping, without testing it, that ensuring the Current link in /Library/Frameworks pointing at the right version would be enough. But, based on the OP's experimentation, you probably need to modify the analogous link in /System/Library as well. Usually it's a bad idea to be modifying anything in /System/Library because anything within it is considered part of OS X and is managed by Apple and, thus, any changes you make can, at best, be erased by the next System Update and, at worst, break your system. In this case, it probably won't make a big difference as the Current link is likely only used in this situation, that is, linking an embedded library. If you are really fastidious, you might consider restoring the original value when you are finished.

Ned Deily
Thank you Ned, this worked great. If you read my post closer, you will find that versions 2.5 and 2.6 were installed in /System/Library/Frameworks, while 3.1 was installed in /Library/Frameworks. The 'Current' symlink in /Library/Frameworks/Python.framework pointed to the correct version (namely 3.1), but the one in /System/Library/Frameworks did not (it pointed to 2.6). When I modified that one, everything started working. If you amend your solution to reflect this fact, I will mark it as the correct answer. Thanks.
Volund