Qt Linux ad ffmpeg6
-
Hi, I have got an incomprensible linking problem with Linux (Debian 12) and ffmpeg 6.
This is my .pro fileQT += 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. -
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> }
-
@mrdebug said in Qt Linux ad ffmpeg6:
The libraries libavcodec.a and the others exist and there are in the right place.
But does it contain above exported symbol? You can check e.g. with
nm -g | c++filt
... -
@mrdebug said in Qt Linux ad ffmpeg6:
The libraries libavcodec.a and the others exist and there are in the right place.
But does it contain above exported symbol? You can check e.g. with
nm -g | c++filt
...denis@tomcat:~/Cpp/ffmpeg-6.0/libavcodec$ nm -g libavcodec.a | grep avcodec_send_packet U avcodec_send_packet 0000000000001080 T avcodec_send_packet U avcodec_send_packet U avcodec_send_packet U avcodec_send_packet U avcodec_send_packet denis@tomcat:~/Cpp/ffmpeg-6.0/libavcodec$
-
denis@tomcat:~/Cpp/ffmpeg-6.0/libavcodec$ nm -g libavcodec.a | grep avcodec_send_packet U avcodec_send_packet 0000000000001080 T avcodec_send_packet U avcodec_send_packet U avcodec_send_packet U avcodec_send_packet U avcodec_send_packet denis@tomcat:~/Cpp/ffmpeg-6.0/libavcodec$
I would take a look in the sources of ffmpeg if this function with the exact signature is in there or e.g. deprecated and therefore not compiled.
-
Hi, I have got an incomprensible linking problem with Linux (Debian 12) and ffmpeg 6.
This is my .pro fileQT += 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.@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.
-
@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.
-
@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.Either you forward declared (wrongly) this function somewhere or you are using the wrong outdated headers.
-
@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.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 foravcodec_send_packet()
declarations. Any chance it is incorrectly declared in one place? -
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 foravcodec_send_packet()
declarations. Any chance it is incorrectly declared in one place? -
@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.
-
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.
-
@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.
@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 isconst AVPacket *
. Which make sit look like there is a declaration and call toAVPacket const*
erroneously somewhere. -
@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 putlibavcodec.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 ;-)
-
@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 putlibavcodec.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 ;-)
@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.
-
@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.
@mrdebug
Try the followingint 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; }
-
@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.
-
@mrdebug
Try the followingint 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; }
-
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> }
-
M mrdebug has marked this topic as solved on