nixprime / cpsm

A CtrlP matcher, specialized for paths.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

ld: library not found for -lintl (macOS with Macports)

rafi opened this issue · comments

Since commit 45676e7 I'm receiving an error while compiling cpsm with Python3 support:
(I'm using macOS with Macports, and not Homebrew)

$ PY3=ON ./install.sh

Python 3 selected by PY3=ON
-- The C compiler identification is AppleClang 9.0.0.9000039
-- The CXX compiler identification is AppleClang 9.0.0.9000039
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - found
-- Found Threads: TRUE
-- Boost version: 1.65.1
-- Found the following Boost libraries:
--   program_options
-- Found PythonInterp: /opt/local/bin/python3 (found suitable version "3.6.4", minimum required is "3")
-- Found PythonInterp: /opt/local/bin/python3 (found version "3.6.4")
-- Found PythonConfig: -I/opt/local/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m -I/opt/local/Library/Frameworks/Python.framework/Versions/3.6/include/python3.6m; -L/opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin -lpython3.6m -lintl -ldl -framework CoreFoundation
-- Found ICU header files in /opt/local/include
-- Found ICU libraries: /opt/local/lib/libicuuc.dylib
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/rafi/.cache/vim/dein/repos/github.com/nixprime/cpsm/build
Scanning dependencies of target cpsm_core
[ 11%] Building CXX object CMakeFiles/cpsm_core.dir/src/str_util.cc.o
[ 22%] Linking CXX static library libcpsm_core.a
[ 22%] Built target cpsm_core
Scanning dependencies of target cpsm_cli
[ 33%] Building CXX object CMakeFiles/cpsm_cli.dir/src/cpsm_cli_main.cc.o
[ 44%] Linking CXX executable cpsm_cli
[ 44%] Built target cpsm_cli
Scanning dependencies of target cpsm_py
[ 55%] Building CXX object CMakeFiles/cpsm_py.dir/src/ctrlp_util.cc.o
[ 66%] Building CXX object CMakeFiles/cpsm_py.dir/src/python_extension.cc.o
[ 77%] Linking CXX shared library cpsm_py.so
ld: library not found for -lintl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [cpsm_py.so] Error 1
make[1]: *** [CMakeFiles/cpsm_py.dir/all] Error 2
make: *** [all] Error 2

I can reproduce this. Still thinking about how to fix it.

python-config is officially recommended over distutils.sysconfig for configuring linking against Python, and the major difference between python-config and the previous distutils.sysconfig-based approach - the addition of $LIBS - was needed to fix #35 by linking against libutil.

In this case, MacPorts links Python against libintl, which is part of gettext, but doesn't put libintl anywhere the system linker will look for it:

$ otool -L /opt/local/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/config-3.6m-darwin/libpython3.6.dylib
...
    	/opt/local/lib/libintl.8.dylib (compatibility version 10.0.0, current version 10.5.0)

As a workaround you can sudo ln -s /opt/local/lib/libintl.8.dylib /usr/local/lib/libintl.8.dylib.

Thanks for the detailed explanation. I've tried symlinking as a work-around, but still getting the same error unfortunately.

Same issue though I'm using homebrew

It seems my issue was related to using asdf version manager. I tried using homebrew python and the build succeeded.

Same here. I'm using python 3.8.6, installed via pyenv on macOS. I tried reinstalling with env PYTHON_CONFIGURE_OPTS="--enable-framework" pyenv install 3.8.6, but running ./install.sh fails with the same output:

Python 3 selected by PY3=ON
-- The C compiler identification is AppleClang 12.0.5.12050022
-- The CXX compiler identification is AppleClang 12.0.5.12050022
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /Library/Developer/CommandLineTools/usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /Library/Developer/CommandLineTools/usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found Boost: /usr/local/include (found version "1.67.0") found components: program_options 
-- Found PythonInterp: /Users/metalelf0/.pyenv/shims/python3 (found suitable version "3.8.6", minimum required is "3") 
-- Found PythonInterp: /Users/metalelf0/.pyenv/shims/python3 (found version "3.8.6") 
-- Found PythonConfig: -I/Users/metalelf0/.pyenv/versions/3.8.6/Library/Frameworks/Python.framework/Versions/3.8/include/python3.8 -I/Users/metalelf0/.pyenv/versions/3.8.6/include/python3.8; -L/Users/metalelf0/.pyenv/versions/3.8.6/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/config-3.8-darwin -lpython3.8 -lintl -ldl -framework CoreFoundation  
-- Optional package ICU was not found
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/metalelf0/.local/share/nvim/site/pack/packer/start/cpsm/build
[ 11%] Building CXX object CMakeFiles/cpsm_core.dir/src/str_util.cc.o
[ 22%] Linking CXX static library libcpsm_core.a
[ 22%] Built target cpsm_core
[ 33%] Building CXX object CMakeFiles/cpsm_cli.dir/src/cpsm_cli_main.cc.o
[ 44%] Linking CXX executable cpsm_cli
[ 44%] Built target cpsm_cli
[ 55%] Building CXX object CMakeFiles/cpsm_py.dir/src/ctrlp_util.cc.o
[ 66%] Building CXX object CMakeFiles/cpsm_py.dir/src/python_extension.cc.o
[ 77%] Linking CXX shared library cpsm_py.so
ld: library not found for -lintl
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make[2]: *** [cpsm_py.so] Error 1
make[1]: *** [CMakeFiles/cpsm_py.dir/all] Error 2
make: *** [all] Error 2

The gettext library that provides libintl is installed via homebrew (I also tried reinstalling and relinking it without success).

@jdsutherland how did you use homebrew python? You installed it and started a shell without loading pyenv, or manually provided some env vars to the install.sh script?

The issue with pyenv may be fixed in v2.3.2 via adding the Homebrew LDFLAGS.