【问题标题】:Compile error when using FFMPEG library使用 FFMPEG 库时编译错误
【发布时间】:2015-01-05 22:15:12
【问题描述】:

我曾尝试使用 FFMPEG 编译 C 程序,但每次编译时都会在 include 语句中失败:

#include <libavcodec/avcodec.h>
#include <libavformat/avformat.h>

Gcc 提供了这个错误信息:

libavcodec/avcodec.h: No such file or directory

我已经安装了 FFMPEG 并创建了共享库,但是当我在编译时尝试链接这些库时,我得到了同样的错误。

gcc main.c -L ffmpeg_build/lib -l ffmpeg_build/include/libavcodec/avcodec.h 

我收到此错误是因为我错误地链接了库,还是有其他问题?

这是我第一次使用别人的图书馆,所以如果我问一个愚蠢的问题,请原谅。

【问题讨论】:

    标签: c gcc linker ffmpeg


    【解决方案1】:

    小写的-l 是一个链接器选项,用于指定。它们可能看起来像 libsomething.a 并在链接器调用中变为 -lsomething。要将目录添加到标题搜索路径,请使用大写 i,-I

    gcc main.c -L/some/path/ffmpeg_build/lib -I/some/path/ffmpeg_build/include
    

    【讨论】:

    • 谢谢,就是这样!
    猜你喜欢
    • 2012-10-05
    • 2013-01-01
    • 2012-08-29
    • 2013-05-28
    • 2018-10-10
    • 2016-12-15
    • 1970-01-01
    • 2014-11-23
    • 1970-01-01
    相关资源
    最近更新 更多