-1

after having compile ffmpeg 6 in Debian 12 with this configure line ./configure --enable-shared I'm trying to compile my first program based on ffmpeg. The source is very short:

extern "C" { // ininfluent

    #include "libavcodec/avcodec.h"
}

int main(int argc, char *argv[])
{

    AVCodecContext *dec_ctx;
    AVPacket *pkt;
    avcodec_send_packet(dec_ctx, pkt);
    return 0;
}

and this is the compile line

gcc -I../../ffmpeg-6.0/ -L. -lavcodec -lavdevice -lavfilter -lavformat -lavutil -lpostproc -lswresample -lswscale main2.cpp

The problem is that I obtain the link error

/usr/bin/ld: /tmp/ccFDv2V6.o: in function `main':
main2.cpp:(.text+0x1e): undefined reference to `avcodec_send_packet'
collect2: error: ld returned 1 exit status

The function avcodec_send_packet exists and it in in the right library. What do I need to do to resolve this error?

πάντα ῥεῖ
  • 1
  • 13
  • 116
  • 190
  • you need to list the libraries after your source file – Alan Birtles Aug 15 '23 at 07:15
  • 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 #include #include } – Denis Gottardello Aug 16 '23 at 07:04
  • This is the right answer because the question is relative to ffmpeg 6 so the question was not already answered. Please remove the wrong links above. – Denis Gottardello Aug 16 '23 at 07:10
  • you're already using `extern "C"`. Not compiling with PIC enabled wont produce undefined references – Alan Birtles Aug 16 '23 at 07:20

0 Answers0