【问题标题】:fatal error: 'libavcodec/avcodec.h' file not found caused by zergon321/reisen致命错误:找不到由 zergon321/reisen 引起的 \'libavcodec/avcodec.h\' 文件
【发布时间】:2022-11-11 07:16:07
【问题描述】:

在导入“github.com/zergon321/reisen”的Mac M2上运行Go代码(重要,因为相关库的安装在Linux上的工作方式不同)我得到了这个:

# github.com/zergon321/reisen
/Users/ido/go/pkg/mod/github.com/zergon321/reisen@v0.1.4/audio.go:4:11: fatal error: 'libavcodec/avcodec.h' file not found
 #include <libavcodec/avcodec.h>
          ^~~~~~~~~~~~~~~~~~~~~~
1 error generated.

我使用 brew 安装了 ffmpeg(包括 libavcodec/avcodec.h 标头)

brew install ffmpeg

但它不会自己捡起来。

【问题讨论】:

    标签: go libav libavcodec


    【解决方案1】:

    这可以解决它:

    1. 如果你确实用 brew 安装了ffmpeg,头文件应该在那里 -> /opt/homebrew/Cellar/ffmpeg/5.1.2/include/libavcodec/avcodec.h(lib 版本可能不同)。 如果由于某种原因不存在,您可以尝试使用find / -name "avcodec.h" 定位头文件
    2. 一旦你建立了avcodec.h 的位置,记下/include 目录的完整路径并运行你的go代码并传递以下标志:
      CGO_CPPFLAGS="-I<path/to/include/directory>" go run <your file name or a period>
      

      我的完整命令如下所示:

      CGO_CPPFLAGS="-I/opt/homebrew/Cellar/ffmpeg/5.1.2/include" go run .
      

    【讨论】:

      猜你喜欢
      • 2018-09-30
      • 2012-08-21
      • 2020-07-02
      • 2020-10-02
      • 2015-01-20
      • 2014-12-21
      • 2013-12-10
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多