Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. "symbol lookup error" if including and using a static library .a on a dynamic Qt plugin .so
Forum Updated to NodeBB v4.3 + New Features

"symbol lookup error" if including and using a static library .a on a dynamic Qt plugin .so

Scheduled Pinned Locked Moved General and Desktop
2 Posts 1 Posters 1.6k Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    cedrix
    wrote on last edited by
    #1

    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 = lib

    DESTDIR = ../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/libavformat

    LIBS += -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.a

    SOURCES += 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.cpp

    HEADERS += 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.h

    unix:!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

    1 Reply Last reply
    0
    • C Offline
      C Offline
      cedrix
      wrote on last edited by
      #2

      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.

      1 Reply Last reply
      0

      • Login

      • Login or register to search.
      • First post
        Last post
      0
      • Categories
      • Recent
      • Tags
      • Popular
      • Users
      • Groups
      • Search
      • Get Qt Extensions
      • Unsolved