记一次编译过程中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)

过程中出现了几个错误:

  1. cmake无法找到pybind11
  2. 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

全部评论
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:/opt/homebrew/include/tsl/include:$CPLUS_INCLUDE_PATH"
点赞 回复 分享
发布于 03-15 03:21 上海

相关推荐

无一技之长怎么办:别去右边,售前,实施,需求分析一起,这是把人当牛马用啊,快跑,这些岗位天花板很低的
点赞 评论 收藏
分享
02-28 17:01
门头沟学院 C++
俊朗的铁猫希望被捞:兄弟如果只想搞钱的话,你这个简历最适合的其实是辅导机构做dai写啥的真的特别赚
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务