[Solved]Qt Mac: can not link ffmpeg library
-
wrote on 22 Sept 2011, 08:46 last edited by
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 privilegesthese 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 -= guiTARGET = ffmpeg_test
CONFIG += console
CONFIG -= app_bundleTEMPLATE = 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 -
wrote on 22 Sept 2011, 09:04 last edited by
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@ -
wrote on 22 Sept 2011, 09:15 last edited by
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 -
wrote on 22 Sept 2011, 09:21 last edited by
And what if you replace
@LIBS += -L/usr/local/lib@
with
@LIBS += -L/usr/local/lib/pkgconfig@
? -
wrote on 22 Sept 2011, 10:17 last edited by
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.
-
wrote on 22 Sept 2011, 22:43 last edited by
Of particular interest is which symbols are not found, these are listed in the compiler output tab.
-
wrote on 23 Sept 2011, 01:11 last edited by
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!
-
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 privilegesthese 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 -= guiTARGET = ffmpeg_test
CONFIG += console
CONFIG -= app_bundleTEMPLATE = 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_64wrote on 17 Jan 2016, 02:32 last edited by@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 ?