[Solved]Qt Mac: can not link ffmpeg library



  • I want to link ffmpeg library using Qt under Mac OS X, but fail.

    My environment are:
    Mac OS X 10.6.4
    xCode 3.2.3
    Qt_SDK_Mac64_offline_v1_1_3_en.dmg
    ffmpeg-0.7.4.tar.bz2


    My step are:
    1). run terminal
    2). type "sudo -s", to administrator privileges

    these steps followed are to compile and install ffmpeg.
    3). type "cd /Volumes/Mac_OS_5/tools/Components/ffmpeg/ffmpeg-0.7.4"
    4). type "./configure --disable-yasm"
    5). type "make"
    6). type "make install"

    after ffmpeg installed, there are directories and files under /usr/local as below:
    @
    /usr/local/include/libavcodec
    /avcodec.h
    /... ...
    /libavdevice
    /avdevice.h
    /... ...
    /libavfilter
    /avfilter.h
    /... ...
    /libavformat
    /avformat.h
    /... ...
    /libavutil
    /avutil.h
    /... ...
    /libswscale
    /swscale.h
    /... ...

    /usr/local/lib/libavcodec.a
    /libavdevice.a
    /libavfilter.a
    /libavformat.a
    /libavutil.a
    /libswscale.a
    /pkgconfig/libavcodec.pc
    /libavdevice.pc
    /libavfilter.pc
    /libavformat.pc
    /libavutil.pc
    /libswscale.pc
    @

    and then I type "ffmpeg", the message is:

    ffmpeg version 0.7.4, Copyright (c) 2000-2011 the FFmpeg developers
    built on Sep 22 2011 16:12:41 with gcc 4.2.1 (Apple Inc. build 5664)
    configuration: --disable-yasm
    libavutil 50. 43. 0 / 50. 43. 0
    libavcodec 52.122. 0 / 52.122. 0
    libavformat 52.110. 0 / 52.110. 0
    libavdevice 52. 5. 0 / 52. 5. 0
    libavfilter 1. 80. 0 / 1. 80. 0
    libswscale 0. 14. 1 / 0. 14. 1
    Hyper fast Audio and Video encoder
    usage: ffmpeg [options] [[infile options] -i infile]... {[outfile options] outfile}...

    it means install ffmpeg successfully.

    these steps followed are to build a test console link with ffmpeg using Qt:
    7). create a "Qt Console Application" save at "/Volumes/Mac_OS_4/test/ffmpeg_test"
    8). copy the ffmpeg headers and libraries to "/Volumes/Mac_OS_4/test/ffmpeg_test", in the same directories with "ffmpeg_test.pro", "main.cpp":

    @
    /Volumes/Mac_OS_4/test/ffmpeg_test/include/libavcodec/avcodec.h
    /... ...

    /Volumes/Mac_OS_4/test/ffmpeg_test/lib/libavcodec.a
    /... ...
    /Volumes/Mac_OS_4/test/ffmpeg_test/lib/pkgconfig/libavcodec.pc
    /... ...
    @

    My code are:
    @
    #ffmpeg_test.pro*******
    QT += core
    QT -= gui

    TARGET = ffmpeg_test
    CONFIG += console
    CONFIG -= app_bundle

    TEMPLATE = app

    SOURCES += main.cpp

    INCLUDEPATH += include

    LIBS += -Llib
    LIBS += -lavcodec
    LIBS += -lavdevice
    LIBS += -lavfilter
    LIBS += -lavformat
    LIBS += -lavutil
    LIBS += -lswscale
    @

    @
    //main.cpp*********
    extern "C" {
    #include "libavcodec/avcodec.h"
    //#include "libavformat/avformat.h"
    };

    int main() {
    avcodec_version();
    return 0;
    }
    @


    But when I try to build, it output build issues:
    symbol(s) not found
    collect2: Id returned 1 exit status


    BTW, when I type "lipo -info libavcodec.a", the message are:
    input file libavcodec.a is not a fat file
    Non-fat file: libavcodec.a is architecture: x86_64



  • You shouldn't copy headers from /usr to your project's folder. Instead you should add following line in the project's .pro file:
    @INCLUDEPATH += /usr/local/include@
    Also you could just change default prefix from /usr/local to /usr in the forth step.

    For successful linking replace in your .pro file this
    @LIBS += -Llib@
    with this
    @LIBS += -L/usr/local/lib@



  • thx all the same.

    though I replace with in the .pro file
    @
    INCLUDEPATH += /usr/local/include
    LIBS += -L/usr/local/lib
    @

    but the error are exist:

    symbol(s) not found
    collect2: Id returned 1 exit status



  • And what if you replace
    @LIBS += -L/usr/local/lib@
    with
    @LIBS += -L/usr/local/lib/pkgconfig@
    ?



  • If you look into the compile messages, there should be some lines detailing why the linker (ld) gave you the error. Can you post those too? It may also be useful you give the last few lines (right before the linker error) in the compile output.



  • Of particular interest is which symbols are not found, these are listed in the compiler output tab.



  • I have resolved this problem.
    by step 4, try to generate share library but no static:
    @
    ./configure --disable-static --enable-shared --disable-yasm
    @

    Thank you all the same!



  • @szuzsq
    I use ffmpeg in Qt on my Mac.I install ffmpeg followring your six step.But I get some error,when I was runnning your Test:
    :-1: warning: argument unused during compilation: '-pthread'
    ld: library not found for -lXfixes
    :-1: error: linker command failed with exit code 1 (use -v to see invocation)
    :-1: error: [FFMPEGTest.app/Contents/MacOS/FFMPEGTest] Error 1.
    Would you like help me ?


Log in to reply
 

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.