Skip to content

"ld: library not found for -lintl" when linking against Pyenv-provided Python on an arm64 Mac #2381

@dnicolson

Description

@dnicolson

Too many issues will kill our team's development velocity, drastically.
Make sure you have checked all steps below.

Prerequisite

  • Make sure your problem is not listed in the common build problems.
  • Make sure no duplicated issue has already been reported in the pyenv issues. You should look for closed issues, too.
  • Make sure you are not asking us to help solving your specific issue.
    • GitHub issues is opened mainly for development purposes. If you want to ask someone to help solving your problem, go to some community site like Gitter, StackOverflow, etc.
  • Make sure your problem is not derived from packaging (e.g. Homebrew).
    • Please refer to the package documentation for the installation issues, etc.
  • Make sure your problem is not derived from plugins.
    • This repository is maintaining pyenv and the default python-build plugin only. Please refrain from reporting issues of other plugins here.

Description

  • Platform information (e.g. Ubuntu Linux 16.04): macOS 12.4 (21F79)
  • OS architecture (e.g. amd64): arm64
  • pyenv version: 2.3.1
  • Python version: 3.10.3
  • C Compiler information (e.g. gcc 7.3): Apple clang version 13.1.6 (clang-1316.0.21.2.5)
  • Please attach the debug trace of the failing command as a gist:
    • Run env PYENV_DEBUG=1 <faulty command> 2>&1 | tee trace.log and attach trace.log. E.g. if you have a problem with installing Python, run env PYENV_DEBUG=1 pyenv install -v <version> 2>&1 | tee trace.log (note the -v option to pyenv install).

Python Autoconf scripts can fail on M1 Macs but not Intel Macs and it appears to be related to gettext being installed by Homebrew in the /opt/homebrew directory instead of /opt/local.

Interestingly, commenting out these lines from the use_homebrew method in python-build appears to resolve the issue.

This works on an Intel Mac:

pyenv install 3.10.3
pyenv shell 3.10.3

cat > test.c <<EOF
#include <Python.h>

int main() {
  Py_Initialize();
}
EOF
gcc test.c $(python-config --cflags --ldflags --embed)

The result on an M1 Mac:

ld: library not found for -lintl
clang: error: linker command failed with exit code 1 (use -v to see invocation)

This works on an M1 Mac:

gcc test.c -L/opt/homebrew/opt/gettext/lib $(python-config --cflags --ldflags --embed)

This works on an M1 Mac after commenting out use_homebrew (lines 1328-1335 in /opt/homebrew/Cellar/pyenv/2.3.1/plugins/python-build/bin/python-build):

pyenv install 3.10.3
gcc test.c $(python-config --cflags --ldflags --embed)

Without use_homebrew:

otool -L ~/.pyenv/versions/3.10.3/bin/python
/Users/dave/.pyenv/versions/3.10.3/bin/python:
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1858.112.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)

With use_homebrew:

otool -L ~/.pyenv/versions/3.10.3/bin/python
/Users/dave/.pyenv/versions/3.10.3/bin/python:
	/System/Library/Frameworks/CoreFoundation.framework/Versions/A/CoreFoundation (compatibility version 150.0.0, current version 1858.112.0)
	/opt/homebrew/opt/gettext/lib/libintl.8.dylib (compatibility version 11.0.0, current version 11.0.0)
	/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1311.100.3)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions