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. Qt Linux ad ffmpeg6
Forum Updated to NodeBB v4.3 + New Features

Qt Linux ad ffmpeg6

Scheduled Pinned Locked Moved Solved General and Desktop
18 Posts 6 Posters 1.3k Views 2 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.
  • mrdebugM mrdebug

    Hi, I have got an incomprensible linking problem with Linux (Debian 12) and ffmpeg 6.
    This is my .pro file

    QT       += core gui
    
    greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
    
    CONFIG += c++17
    
    # You can make your code fail to compile if it uses deprecated APIs.
    # In order to do so, uncomment the following line.
    #DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000    # disables all the APIs deprecated before Qt 6.0.0
    
    INCLUDEPATH += ../../ffmpeg-6.0/
    LIBS += ../../ffmpeg-6.0/libavcodec/libavcodec.a
    LIBS += ../../ffmpeg-6.0/libavdevice/libavdevice.a
    LIBS += ../../ffmpeg-6.0/libavfilter/libavfilter.a
    LIBS += ../../ffmpeg-6.0/libavformat/libavformat.a
    LIBS += ../../ffmpeg-6.0/libavutil/libavutil.a
    #LIBS += ../../ffmpeg-6.0/libpostproc/libpostproc.a
    LIBS += ../../ffmpeg-6.0/libswresample/libswresample.a
    LIBS += ../../ffmpeg-6.0/libswscale/libswscale.a
    LIBS += ../../ffmpeg-6.0/libavcodec/decode.o
    
    SOURCES += \
        main.cpp \
        qfmainwindow.cpp
    
    HEADERS += \
        qfmainwindow.h
    
    FORMS += \
        qfmainwindow.ui
    
    # Default rules for deployment.
    qnx: target.path = /tmp/$${TARGET}/bin
    else: unix:!android: target.path = /opt/$${TARGET}/bin
    !isEmpty(target.path): INSTALLS += target
    

    but on linking time I obtain this error:

    /home/denis/Cpp/ffmpegTest/ffmpegTest/main.cpp:-1: error: undefined reference to `avcodec_send_packet(AVCodecContext*, AVPacket const*)'
    

    The libraries libavcodec.a and the others exist and there are in the right place.
    I haven't got this type of error using the old version 4.2.2.

    JoeCFDJ Offline
    JoeCFDJ Offline
    JoeCFD
    wrote on last edited by
    #5

    @mrdebug
    from here: https://ffmpeg.org/doxygen/3.1/avcodec_8h.html
    The interface might have been changed.
    avcodec_send_packet (AVCodecContext *avctx, const AVPacket *avpkt)

    your call avcodec_send_packet(AVCodecContext*, AVPacket const*) is not right in the main.cpp. const is missed.

    mrdebugM 1 Reply Last reply
    1
    • JoeCFDJ JoeCFD

      @mrdebug
      from here: https://ffmpeg.org/doxygen/3.1/avcodec_8h.html
      The interface might have been changed.
      avcodec_send_packet (AVCodecContext *avctx, const AVPacket *avpkt)

      your call avcodec_send_packet(AVCodecContext*, AVPacket const*) is not right in the main.cpp. const is missed.

      mrdebugM Offline
      mrdebugM Offline
      mrdebug
      wrote on last edited by
      #6

      @JoeCFD Adding "const" has no affect.
      By the way the problem is not at compile time but linking time.
      I trying the 3 functions founded in the example ffmpeg-6.0/doc/examples/decode_video.c placed in a Qt empty project.

      Need programmers to hire?
      www.labcsp.com
      www.denisgottardello.it
      GMT+1
      Skype: mrdebug

      Christian EhrlicherC JonBJ 2 Replies Last reply
      0
      • mrdebugM mrdebug

        @JoeCFD Adding "const" has no affect.
        By the way the problem is not at compile time but linking time.
        I trying the 3 functions founded in the example ffmpeg-6.0/doc/examples/decode_video.c placed in a Qt empty project.

        Christian EhrlicherC Offline
        Christian EhrlicherC Offline
        Christian Ehrlicher
        Lifetime Qt Champion
        wrote on last edited by
        #7

        Either you forward declared (wrongly) this function somewhere or you are using the wrong outdated headers.

        Qt Online Installer direct download: https://download.qt.io/official_releases/online_installers/
        Visit the Qt Academy at https://academy.qt.io/catalog

        1 Reply Last reply
        1
        • mrdebugM mrdebug

          @JoeCFD Adding "const" has no affect.
          By the way the problem is not at compile time but linking time.
          I trying the 3 functions founded in the example ffmpeg-6.0/doc/examples/decode_video.c placed in a Qt empty project.

          JonBJ Offline
          JonBJ Offline
          JonB
          wrote on last edited by
          #8

          @mrdebug

          undefined reference to `avcodec_send_packet(AVCodecContext*, AVPacket const*)`
          

          Since the last parameter ought be const AVPacket *, and (C++ expert correct me if I am wrong) AVPacket const * is not the same thing, I am with @Christian-Ehrlicher: start by searching all your sources and all that you include for avcodec_send_packet() declarations. Any chance it is incorrectly declared in one place?

          JoeCFDJ 1 Reply Last reply
          0
          • JonBJ JonB

            @mrdebug

            undefined reference to `avcodec_send_packet(AVCodecContext*, AVPacket const*)`
            

            Since the last parameter ought be const AVPacket *, and (C++ expert correct me if I am wrong) AVPacket const * is not the same thing, I am with @Christian-Ehrlicher: start by searching all your sources and all that you include for avcodec_send_packet() declarations. Any chance it is incorrectly declared in one place?

            JoeCFDJ Offline
            JoeCFDJ Offline
            JoeCFD
            wrote on last edited by
            #9

            @JonB const AVPacket * means: const instance of AVPacket. Only const funcs of class AVPacket can be called.
            AVPacket const * means: this is a constant pointer and its address can be changed.

            Two different things.

            mrdebugM JonBJ 2 Replies Last reply
            0
            • JoeCFDJ JoeCFD

              @JonB const AVPacket * means: const instance of AVPacket. Only const funcs of class AVPacket can be called.
              AVPacket const * means: this is a constant pointer and its address can be changed.

              Two different things.

              mrdebugM Offline
              mrdebugM Offline
              mrdebug
              wrote on last edited by
              #10

              The code is good because executing "make examples", the example from I have copied out the functions waw been compiled. I think the problem is related to some switch to add at the .pro file.

              Need programmers to hire?
              www.labcsp.com
              www.denisgottardello.it
              GMT+1
              Skype: mrdebug

              JoeCFDJ 1 Reply Last reply
              0
              • mrdebugM mrdebug

                The code is good because executing "make examples", the example from I have copied out the functions waw been compiled. I think the problem is related to some switch to add at the .pro file.

                JoeCFDJ Offline
                JoeCFDJ Offline
                JoeCFD
                wrote on last edited by JoeCFD
                #11

                @mrdebug the order of the libs matters. Change the order of static libs in the pro file.

                JonBJ 1 Reply Last reply
                0
                • JoeCFDJ JoeCFD

                  @JonB const AVPacket * means: const instance of AVPacket. Only const funcs of class AVPacket can be called.
                  AVPacket const * means: this is a constant pointer and its address can be changed.

                  Two different things.

                  JonBJ Offline
                  JonBJ Offline
                  JonB
                  wrote on last edited by
                  #12

                  @JoeCFD said in Qt Linux ad ffmpeg6:

                  Two different things.

                  I know. And the error message AVPacket const* does not match what it should be, which is const AVPacket *. Which make sit look like there is a declaration and call to AVPacket const* erroneously somewhere.

                  1 Reply Last reply
                  0
                  • JoeCFDJ JoeCFD

                    @mrdebug the order of the libs matters. Change the order of static libs in the pro file.

                    JonBJ Offline
                    JonBJ Offline
                    JonB
                    wrote on last edited by
                    #13

                    @JoeCFD said in Qt Linux ad ffmpeg6:

                    @mrdebug the order of the libs matters. Change the order of static libs in the pro file.

                    This is a good point. @mrdebug: do you call avcodec_send_packet() from your own code (e.g. main.cpp)? Because if not, and its internal, and you put libavcodec.a as the first library, and only a later library calls that function, it may not have been included. Do you get that order/list of linking the libraries from some documentation?

                    I haven't got this type of error using the old version 4.2.2.

                    Hmm ;-)

                    mrdebugM 1 Reply Last reply
                    0
                    • JonBJ JonB

                      @JoeCFD said in Qt Linux ad ffmpeg6:

                      @mrdebug the order of the libs matters. Change the order of static libs in the pro file.

                      This is a good point. @mrdebug: do you call avcodec_send_packet() from your own code (e.g. main.cpp)? Because if not, and its internal, and you put libavcodec.a as the first library, and only a later library calls that function, it may not have been included. Do you get that order/list of linking the libraries from some documentation?

                      I haven't got this type of error using the old version 4.2.2.

                      Hmm ;-)

                      mrdebugM Offline
                      mrdebugM Offline
                      mrdebug
                      wrote on last edited by
                      #14

                      @JonB Hi, I have tried to edit the libraries order without any effect.
                      Now code is:

                      #include <libavutil/frame.h>
                      #include <libavutil/mem.h>
                      #include <libavcodec/avcodec.h>
                      
                      int main(int argc, char *argv[])
                      {
                          AVCodecContext *dec_ctx;
                          AVPacket *pkt;
                          avcodec_send_packet(dec_ctx, pkt);
                          return 0;
                      }
                      

                      and the .pro file is the one above. The error is the same:

                      /home/denis/Cpp/ffmpegTest/ffmpegTest/main.cpp:25: error: undefined reference to `avcodec_send_packet(AVCodecContext*, AVPacket const*)'
                      

                      and to include only the library (libavcodec.a) that contains the function does not resolve.

                      Need programmers to hire?
                      www.labcsp.com
                      www.denisgottardello.it
                      GMT+1
                      Skype: mrdebug

                      JoeCFDJ SGaistS 2 Replies Last reply
                      0
                      • mrdebugM mrdebug

                        @JonB Hi, I have tried to edit the libraries order without any effect.
                        Now code is:

                        #include <libavutil/frame.h>
                        #include <libavutil/mem.h>
                        #include <libavcodec/avcodec.h>
                        
                        int main(int argc, char *argv[])
                        {
                            AVCodecContext *dec_ctx;
                            AVPacket *pkt;
                            avcodec_send_packet(dec_ctx, pkt);
                            return 0;
                        }
                        

                        and the .pro file is the one above. The error is the same:

                        /home/denis/Cpp/ffmpegTest/ffmpegTest/main.cpp:25: error: undefined reference to `avcodec_send_packet(AVCodecContext*, AVPacket const*)'
                        

                        and to include only the library (libavcodec.a) that contains the function does not resolve.

                        JoeCFDJ Offline
                        JoeCFDJ Offline
                        JoeCFD
                        wrote on last edited by
                        #15

                        @mrdebug
                        Try the following

                        int main(int argc, char *argv[])
                        {
                            AVCodecContext *dec_ctx{};
                            const AVPacket *pkt{};
                            avcodec_send_packet(dec_ctx, pkt);
                            return 0;
                        }
                        

                        or

                        int main(int argc, char *argv[])
                        {
                            AVCodecContext *dec_ctx{};
                            AVPacket * const pkt{};
                            avcodec_send_packet(dec_ctx, pkt);
                            return 0;
                        }
                        
                        mrdebugM 1 Reply Last reply
                        0
                        • mrdebugM mrdebug

                          @JonB Hi, I have tried to edit the libraries order without any effect.
                          Now code is:

                          #include <libavutil/frame.h>
                          #include <libavutil/mem.h>
                          #include <libavcodec/avcodec.h>
                          
                          int main(int argc, char *argv[])
                          {
                              AVCodecContext *dec_ctx;
                              AVPacket *pkt;
                              avcodec_send_packet(dec_ctx, pkt);
                              return 0;
                          }
                          

                          and the .pro file is the one above. The error is the same:

                          /home/denis/Cpp/ffmpegTest/ffmpegTest/main.cpp:25: error: undefined reference to `avcodec_send_packet(AVCodecContext*, AVPacket const*)'
                          

                          and to include only the library (libavcodec.a) that contains the function does not resolve.

                          SGaistS Offline
                          SGaistS Offline
                          SGaist
                          Lifetime Qt Champion
                          wrote on last edited by
                          #16

                          @mrdebug hi,

                          Can you show the .pro file of your minimal project ?
                          Are you sure you are linking to the expected version of ffmpeg ?
                          Do you have your distribution provided ffmpeg development packages installed ?

                          Interested in AI ? www.idiap.ch
                          Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

                          1 Reply Last reply
                          0
                          • JoeCFDJ JoeCFD

                            @mrdebug
                            Try the following

                            int main(int argc, char *argv[])
                            {
                                AVCodecContext *dec_ctx{};
                                const AVPacket *pkt{};
                                avcodec_send_packet(dec_ctx, pkt);
                                return 0;
                            }
                            

                            or

                            int main(int argc, char *argv[])
                            {
                                AVCodecContext *dec_ctx{};
                                AVPacket * const pkt{};
                                avcodec_send_packet(dec_ctx, pkt);
                                return 0;
                            }
                            
                            mrdebugM Offline
                            mrdebugM Offline
                            mrdebug
                            wrote on last edited by
                            #17

                            @JoeCFD Tried both. The behaviour is the same.
                            Tomorrow I'll try on a Mac and Windows

                            Need programmers to hire?
                            www.labcsp.com
                            www.denisgottardello.it
                            GMT+1
                            Skype: mrdebug

                            mrdebugM 1 Reply Last reply
                            0
                            • mrdebugM mrdebug

                              @JoeCFD Tried both. The behaviour is the same.
                              Tomorrow I'll try on a Mac and Windows

                              mrdebugM Offline
                              mrdebugM Offline
                              mrdebug
                              wrote on last edited by
                              #18

                              Hi, in order to use ffmpeg 6 libraries in a custom software it is mandatory to compile the source using this swich "--enable-pic"
                              and include the header in this way:

                              extern "C" {
                                  #include <libavutil/frame.h>
                                  #include <libavutil/mem.h>
                                  #include <libavcodec/avcodec.h>
                              }
                              

                              Need programmers to hire?
                              www.labcsp.com
                              www.denisgottardello.it
                              GMT+1
                              Skype: mrdebug

                              1 Reply Last reply
                              0
                              • mrdebugM mrdebug has marked this topic as solved on

                              • Login

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