Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong output for python3-config --ldflags #1761

Closed
ppwwyyxx opened this issue May 24, 2017 · 9 comments
Closed

Wrong output for python3-config --ldflags #1761

ppwwyyxx opened this issue May 24, 2017 · 9 comments

Comments

@ppwwyyxx
Copy link

Just install anaconda for python3.6 on macos sierra, with the graphical installer.
After the installation:

$ python3-config --ldflags
-lpython3.6m -ldl -framework CoreFoundation -Wl,-stack_size,1000000 -framework CoreFoundation

Two things:

  1. It should include -L/Users/xxx/anaconda/lib in ldflags as well, otherwise a compiler cannot find -lpython3.6m. This is done in anaconda Linux, also in non-conda python.
  2. Why -stack_size,1000000? Clang complains that this flag is only valid when linking an executable, while I'm linking a shared library.
@nofacer
Copy link

nofacer commented Jul 14, 2017

Hi I just came across the same error when build another project and finally found the solution. Just modify the makefile manually like this:
PYLIBS := -L/Users/Your_name/anaconda3/lib/python3.6/config-3.6m-darwin -lpython3.6m -ldl -framework CoreFoundation

@Atry
Copy link

Atry commented Jan 31, 2018

This bug is introduced by CPython:
https://github.com/python/cpython/blob/8c9bb72e8b6474ae722f7d6521cfb3cb2e26e3c5/configure.ac#L2614

It has been workaround in anaconda's python 3.5:
ContinuumIO/anaconda-recipes@931bfba

However, other 3.x versions of anaconda's python still produce wrong ldflags.

@mingwandroid
Copy link

mingwandroid commented Jan 31, 2018 via email

@Atry
Copy link

Atry commented Jan 31, 2018

@mingwandroid Wrong ldflags as described in @ppwwyyxx's post.

@mingwandroid
Copy link

python3-config --ldflags returns the linker flags for embedding Python in another application, it does not give the linker flags for compiling a Python extension module. To get those you need to run the following:

python -c "import sysconfig; print(sysconfig.get_config_vars('LDSHARED'))"

@mingwandroid
Copy link

mingwandroid commented Jan 31, 2018

It should include -L/Users/xxx/anaconda/lib

.. now-a-days, (since AD 5.0) our Python interpreter is statically linked on macOS and thus prefers to be statically linked, so:

python3-config --ldflags
-L/opt/conda/lib/python3.6/config-3.6m-darwin -lpython3.6m -ldl -framework CoreFoundation -Wl,-stack_size,1000000 -framework CoreFoundation
ls /opt/conda/lib/python3.6/config-3.6m-darwin
lrwxr-xr-x  1 rdonnelly  admin     21 23 Jan 12:14 libpython3.6m.a -> ../../libpython3.6m.a

.. is just fine.

@saraedum
Copy link

@mingwandroid Interesting, so Debian/Ubuntu gets this wrong on their man-page: http://manpages.ubuntu.com/manpages/xenial/en/man1/i386-linux-gnu-python2.7-config.1.html

saraedum added a commit to saraedum/staged-recipes that referenced this issue Feb 17, 2018
saraedum added a commit to saraedum/staged-recipes that referenced this issue Feb 17, 2018
@mingwandroid
Copy link

Yes it looks like they do indeed get it wrong here! You should note, the python build scripts from Debian/Ubuntu are what inspired me to switch to a static interpreter, that and the prompting of @pitrou

saraedum added a commit to saraedum/staged-recipes that referenced this issue Feb 17, 2018
saraedum added a commit to saraedum/staged-recipes that referenced this issue Feb 17, 2018
@saraedum
Copy link

Ok. I wrote an email to the author of the man-page.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants