[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 © 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
6 replies
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
You must log in to post a reply. Not a member yet? Register here!



