Qt Linux ad ffmpeg6
-
@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