"symbol lookup error" if including and using a static library .a on a dynamic Qt plugin .so
-
Hello,
I am trying to make a qt multimedia plugin (ffmpeg backend) but I can't find out how to compile a shared .so library and add inside a static library. Here is my pro file:
@QT += multimedia multimedia-private
qtHaveModule(widgets) {
QT += multimediawidgets-private
DEFINES += HAVE_WIDGETS
}PLUGIN_TYPE=mediaservice
PLUGIN_CLASS_NAME = FFmpegServicePlugin
load(qt_build_config)QT -= gui
TARGET = FFmpegMultimediaPlugin
TEMPLATE = libDESTDIR = ../binaries/plugins/mediaservice
OBJECTS_DIR = ../tmpcompil/$$TARGET/obj
MOC_DIR = ../tmpcompil/$$TARGET/moc
RCC_DIR = ../tmpcompil/$$TARGET/rcc
UI_DIR = ../tmpcompil/$$TARGET/ui#ffmpeg
unix{
DEFINES += __STDC_LIMIT_MACROS
DEFINES += __STDC_CONSTANT_MACROS
}INCLUDEPATH += ffmpeg
INCLUDEPATH += ffmpeg/libavcodec
INCLUDEPATH += ffmpeg/libavformatLIBS += -L$$PWD/ffmpeg/libavcodec -lavcodec
LIBS += -L$$PWD/ffmpeg/libavformat -lavformat
LIBS += -L$$PWD/ffmpeg/libavutil -lavutil
#QMAKE_CXXFLAGS += $$PWD/ffmpeg/libavcodec/libavcodec.a
#QMAKE_CXXFLAGS += $$PWD/ffmpeg/libavformat/libavformat.a
#QMAKE_CXXFLAGS += $$PWD/ffmpeg/libavutil/libavutil.aSOURCES += ffmpegmultimediaplugin.cpp
mediaPlayer/ffmpegmediaplayercontrol.cpp
mediaPlayer/ffmpegplayerservice.cpp
mediaPlayer/ffmpegvideowidgetcontrol.cpp
mediaPlayer/ffmpegvideorendercontrol.cpp
mediaPlayer/ffmpegmetadatareadercontrol.cpp
mediaPlayer/ffmpegmediaavailabilitycontrol.cpp
mediaPlayer/ffmpegmedianetworkaccesscontrol.cpp
audioDecoder/ffmpegaudiodecoderservice.cpp
audioDecoder/ffmpegaudiodecodercontrol.cppHEADERS += ffmpegmultimediaplugin.h
mediaPlayer/ffmpegmediaplayercontrol.h
mediaPlayer/ffmpegplayerservice.h
mediaPlayer/ffmpegvideowidgetcontrol.h
mediaPlayer/ffmpegvideorendercontrol.h
mediaPlayer/ffmpegmetadatareadercontrol.h
mediaPlayer/ffmpegmediaavailabilitycontrol.h
mediaPlayer/ffmpegmedianetworkaccesscontrol.h
audioDecoder/ffmpegaudiodecoderservice.h
audioDecoder/ffmpegaudiodecodercontrol.hunix:!symbian {
maemo5 {
target.path = /opt/usr/lib
} else {
target.path = /usr/lib
}
INSTALLS += target
}OTHER_FILES +=
ffmpeg.json
@I tried severals things such as doing the linking this way:
@-L/home/cedric/code/QMediaLearner/FFmpegMultimediaPlugin/ffmpeg/libavformat -Wl,-Bstatic -lz -lavformat -L/home/cedric/code/QMediaLearner/FFmpegMultimediaPlugin/ffmpeg/libavcodec -Wl,-Bstatic -lz -lavcodec -L/home/cedric/code/QMediaLearner/FFmpegMultimediaPlugin/ffmpeg/libavutil -Wl,-Bstatic -lz -lavutil@
or adding to g++
@/home/cedric/code/QMediaLearner/FFmpegMultimediaPlugin/ffmpeg/libavformat/libavformat.a@Whatever i do, my so file ends up the same size and when I use it, I got this error:
@/home/cedric/code/QMediaLearner/Desktop_Qt_5_1_0_GCC_64bit_Debug/binaries/QMediaLearner: symbol lookup error: /home/cedric/Qt5.1.0/5.1.0/gcc_64/plugins/mediaservice/libFFmpegMultimediaPlugin.so.1.0.0: undefined symbol: _Z19avformat_open_inputPP15AVFormatContextPKcP13AVInputFormatPP12AVDictionary@
On a simple qt gui application it works however. I feel like the linking is ignored if making a qt plugin.
Anyone know what is going on and how to fixe this?
Thanks in advance,
Cédric
-
I forgot to say that I am using c library. One option is to add extern C{} when I include the ffmpeg library files. But then I can't compile and get those errors:
@:-1: erreur : /home/cedric/code/QMediaLearner/FFmpegMultimediaPlugin/ffmpeg/libavformat/libavformat.a(utils.o): relocation R_X86_64_32 against `.rodata.str1.1' can not be used when making a shared object; recompile with -fPIC@But with
@QMAKE_CXXFLAGS += -fPIC@
the error remains.