-
Notifications
You must be signed in to change notification settings - Fork 48
Description
On macOS in a new virtual environment, building PySCF-Forge from source by running
export CMAKE_CONFIGURE_ARGS="-DCMAKE_C_COMPILER=gcc-14 -DCMAKE_CXX_COMPILER=g++-14"
pip install git+https://github.com/pyscf/pyscf-forge.gitresults in a linker error (build.log log for full output)
[ 90%] Linking C shared library /private/var/folders/1j/0rqv9z_52f11z6t_rcrxr2sh0000gn/T/pip-req-build-q3p68ef0/pyscf/lib/libxc_itrf2.dylib
ld: warning: search path '/usr/local/lib64' not found
ld: library 'xc' not found
collect2: error: ld returned 1 exit status
make[2]: *** [/private/var/folders/1j/0rqv9z_52f11z6t_rcrxr2sh0000gn/T/pip-req-build-q3p68ef0/pyscf/lib/libxc_itrf2.dylib] Error 1
make[1]: *** [CMakeFiles/clib_libxc_itrf2.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
Since PySCF is a build and runtime dependency, Pip is using a temporary installation of PySCF for linking. I don't think this is necessarily and issue, make debugging slightly more complicated.
Work-Around
Use a copy of LibXC provided by Homebrew by setting
export LIBRARY_PATH="/opt/homebrew/lib"
export C_INCLUDE_PATH="/opt/homebrew/include"
export CPLUS_INCLUDE_PATH="/opt/homebrew/lib"See https://github.com/MatthewRHermes/mrh?tab=readme-ov-file#installing-on-macos
Hacky Fix
I cloned PySCF-Forge and built from the local source. After installing PySCF ls $VIRTUAL_ENV/lib/python3.13/site-packages/pyscf/lib/deps/lib shows
libcint.6.dylib* libxc.15.dylib* libxcfun.2.dylib*
In the PySCF-Forge, changing the line
target_link_libraries (clib_libxc_itrf2 xc ${OPENMP_C_PROPERTIES})
# Change to
target_link_libraries (clib_libxc_itrf2 "xc.15" ${OPENMP_C_PROPERTIES})in pyscf-forge/pyscf/lib/CMakeLists.txt fixes the issue after running pip install ./pyscf-forge; however, this not the right solution.
This may be a quirk in how .dylibs are linked. Probably the correct fix would be to use find_package(LibXC) tell CMake to favor the PySCF provided version. I don't mind working on this, but I wanted to get some feedback first.
System Specs
macOS Sequoia v15.5
Compiler GCC-14 from Homebrew to avoid OpenMP issues.
Python 3.9, 3.13
PySCF-Forge from master
PySCF from PyPi and master
Thanks for your help!