在Mac上运行Go代码(重要的是,因为相关M2的安装在Linux上的工作方式不同),导入"github.com/zergon321/reisen“时,我得到了以下结果:
# 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但它不是自己捡起来的。
发布于 2022-10-26 13:37:14
这个方法成功地解决了这个问题:
如果您确实用brew安装了
/opt/homebrew/Cellar/ffmpeg/5.1.2/include/libavcodec/avcodec.h (lib版本可能有所不同)。如果由于某种原因它不在那里,您可以尝试使用find / -name "avcodec.h"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 .https://stackoverflow.com/questions/74208773
复制相似问题