【问题标题】:Undefined Referernce Errors FFMPEG + QT + Ubuntu 12.04.2 LTS未定义的引用错误 FFMPEG + QT + Ubuntu 12.04.2 LTS
【发布时间】:2013-07-19 09:12:11
【问题描述】:

我有 2 台装有 Ubuntu 12.04.2 LTS (64 mb) 的机器,另一台是雪豹操作系统。 在我的 Mac 中,我使用 ffmpeg 没有任何问题,但随后我尝试在 ubuntu 中使用 ffmpeg,出现 6700(!)错误:

error: undefined reference to `av_freep'
error: undefined reference to `av_strstart'
error: undefined reference to `av_freep'
...

我使用 QT 4.8.5 和 g++ x86 64b 我在http://ffmpeg.org/trac/ffmpeg/wiki/UbuntuCompilationGuide 之后安装了ffmpeg,没有出现错误或警告。

我的测试代码是:

.h

QT += core gui 

INCLUDEPATH += \
    /usr/local/Include

LIBS += /usr/local/lib/libavcodec.a
LIBS += /usr/local/lib/libavutil.a
LIBS += /usr/local/lib/libavformat.a
LIBS += /usr/local/lib/libswscale.a


SOURCES += main.cpp

.cpp:

extern "C"
{
#ifndef __STDC_CONSTANT_MACROS
#  define __STDC_CONSTANT_MACROS
#endif

#include "libavcodec/avcodec.h"
#include "libavformat/avformat.h"
}

#include <stdio.h>

int main()
{
    AVFormatContext *pFormatCtx;
    av_register_all();

    const char* fil = "/home/cits/Desktop/movFile.mov";

    if(avformat_open_input(&pFormatCtx, fil, NULL, NULL)!=0)
    {
        return -1; // Couldn't open file
    }

    if(avformat_find_stream_info(pFormatCtx, NULL)<0)
    {
        return -1; // Couldn't find stream information
    }

    return 0;
}

有什么想法吗??

提前致谢。

【问题讨论】:

    标签: qt ubuntu linker ffmpeg


    【解决方案1】:

    您的 .pro 文件应如下所示:

    QT += core gui 
    
    INCLUDEPATH += \
        /usr/local/Include
    
    LIBS += -L/usr/local/lib/ -llibavcodec -llibavutil -llibavformat -llibswscale
    
    
    SOURCES += main.cpp
    

    【讨论】:

    • 如果我这样做,我会得到:错误:找不到 -llibavcodec 错误:找不到 -llibavutil 错误:找不到 -llibavformat 等 在 /usr/local/lib 我有 libavcodec.a libavformat.a libdevice .a libavutil.a libavfilter.a libswscale.a 和 libswresample.a
    • 是的,我查过了。 ffmpeg 编译将其放入其中。
    • 一般应该自动添加扩展名,但可以尝试使用-llibavcodec.a-lavcodec-lavcodec.a调用它
    • 我想知道这些库中是否真的定义了av_freep,也许还有另一个具有所需功能的avlib?
    猜你喜欢
    • 1970-01-01
    • 2012-03-16
    • 1970-01-01
    • 1970-01-01
    • 2012-04-23
    • 2019-11-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多