This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: python-config --ldflags doesn't pick up libpython2.5.a
Type: compile error Stage: resolved
Components: macOS Versions: Python 2.7, Python 2.6, Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: ronaldoussoren Nosy List: robince, ronaldoussoren
Priority: normal Keywords:

Created on 2009-12-18 16:28 by robince, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg96569 - (view) Author: Robin (robince) Date: 2009-12-18 16:28
Using my python.org install:
robin-mbp:~ robince$ which python-config
/Library/Frameworks/Python.framework/Versions/2.5/bin/python-config
robin-mbp:~ robince$ python-config --ldflags
-L/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config
-ldl -lpython2.5

But if I build a C file with python embedded, the above linker flags
result it in it embedding the system python. Obviously the -lpython2.5
is picking up the system one in preference to the one on the -L path.

From Ronald Oussoren on pythonmac-sig:

The easiest workaround is to open a terminal window and execute the 
following commands:

  cd 
/Library/Frameworks/Python.framework/Versions/2.5/lib/python2.5/config
  ln -s libpython2.5.a libpython2.5.dylib

This will ensure that the OSX linker knows that libpython is a shared 
library and links to this library. By default the OSX linker searches 
for a .dylib on the entire linker path and only then looks for .a files.
msg96858 - (view) Author: Ronald Oussoren (ronaldoussoren) * (Python committer) Date: 2009-12-24 14:25
Fixed in r77033 (trunk), r77034 (2.6), r77035 (py3k), r77036 (3.1)

Development on the 2.5 tree is closed, I will therefore not backport to 
2.5.

As a workaround you can add -Wl,-search_paths_first to the linker flags to 
ensure that the libpython.a in the framework gets picked up before 
/usr/lib/libpython2.5.dylib.
History
Date User Action Args
2022-04-11 14:56:55adminsetgithub: 51790
2009-12-24 14:25:32ronaldoussorensetstatus: open -> closed
type: compile error
messages: + msg96858

resolution: fixed
stage: resolved
2009-12-18 16:28:07robincecreate