记一次编译过程中fix error的经历
3/10/25 需要使用LLVM binding Python的功能,于是在llvm-project的build文件夹里运行
cmake -G Ninja ../llvm \ -DLLVM_ENABLE_PROJECTS="mlir" \ -DCMAKE_BUILD_TYPE=Release \ -DLLVM_TARGETS_TO_BUILD="host" \ -DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_INSTALL_UTILS=ON \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ -DPython3_EXECUTABLE=$(which python3)
过程中出现了几个错误:
- cmake无法找到pybind11
- cmake无法找到nanobind
为了解决错误1,我首先pip install pybind11。安装成功后还是无法找到。然后我使用virtual environment装但是报错:× This environment is externally managed ╰─> To install Python packages system-wide, try brew install xyz, where xyz is the package you are trying to install.
于是使用brew install pybind11
brew link pybind11
brew info pybind11
另外一些debug Python package安装路径和指定安装地址的命令行“
import sys
print(sys.path)
python -c "import nanobind; print(nanobind.__path__)"
/opt/homebrew/bin/python3 -m pip install pybind11
成功之后需要修改环境变量:
export CPLUS_INCLUDE_PATH="/opt/homebrew/lib/python3.12/site-packages/nanobind/include:**********/3.12.4/Frameworks/Python.framework/Versions/3.12/include/python3.12:$CPLUS_INCLUDE_PATH"
source ~/.zshrc
安装完毕后又有找不到C++头文件的错误:
packages/nanobind/src/nb_internals.h:15:10: fatal error: 'tsl/robin_map.h' file not found 15 | #include <tsl/robin_map.h> | ^~~~~~~~~~~~~~~~~ 1 error generated.
因为网络问题,手动下载robin-map项目再添加到所需要的文件夹下:
unzip robin-map-master.zip mv robin-map-master /opt/homebrew/include/tsl