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

相关推荐

04-17 18:32
门头沟学院 Java
野猪不是猪🐗:他跟你一个学校,你要是进来之后待遇比他好,他受得了?
点赞 评论 收藏
分享
05-30 12:03
山西大学 C++
offer来了我跪着接:不是骗子,等到测评那一步就知道为啥这么高工资了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务