<div dir="ltr"><div><div>I installed the ffmpeg library following <a href="https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu">https://trac.ffmpeg.org/wiki/CompilationGuide/Ubuntu</a><br></div><div>on a Debian computer, but I could not compile or link.<br></div><div>Then I installed the ffmpeg at usr/local accordingly:<br><a href="https://trac.ffmpeg.org/wiki/How%20to%20quickly%20compile%20FFmpeg%20with%20opus%20and%20x264">https://trac.ffmpeg.org/wiki/How%20to%20quickly%20compile%20FFmpeg%20with%20opus%20and%20x264</a><br></div><div><br></div><div>Then I can compile and link using the following command line:<br>gcc  -o ffmpeg_grabber ffmpeg_grabber_03.c -Wall -ggdb $(pkg-config --cflags libavformat libavcodec libswresample libswscale libavutil sdl) $(pkg-config --libs libavformat libavcodec libswresample libswscale libavutil sdl) -lm
<br><br></div><div>But I have a lot of link errors (undefined a lot of things) removing pkg-config:<br>gcc  -o test test.c -Wall -lavformat -lavcodec -lswresample -lswscale -lavutil -lm<br><br></div><div>The question is: How to avoid undefine errors without using the pkg-config?<br></div><div><br></div>code:<br><br>#include <stdio.h>
<br>#ifndef inline
<br>#define inline __inline
<br>#endif
<br>#ifndef UINT64_C
<br>#define UINT64_C uint64_t
<br>#define INT64_C int64_t
<br>#endif//end extern "C"
<br>#include "libavcodec/avcodec.h"
<br>#include "libavformat/avformat.h"
<br>#include "libswscale/swscale.h"
<br>//Avoid undefined PIX_FMT_RGB24
<br>#ifndef PIX_FMT_RGB24
<br>#define PIX_FMT_RGB24 AV_PIX_FMT_RGB24    
<br>#endif
<br>// compatibility with newer API
<br>#if LIBAVCODEC_VERSION_INT < AV_VERSION_INT(55,28,1)
<br>#define av_frame_alloc avcodec_alloc_frame
<br>#define av_frame_free avcodec_free_frame
<br>#endif
<br> <br> <br>int main(int argc, char *argv[]) 
<br>{
<br>  av_register_all();
<br>  return 0;
<br>}
<br><br><br></div><div>Here are a lot of command line failing trials:<br>Do not compiles under linux:
<br>gcc -o ffmpeg_grabber ffmpeg_grabber.c -I/home/acciona/ffmpeg_build/include -lavutil -lavformat -lavcodec -lz -lm
<br>gcc -o ffmpeg_grabber ffmpeg_grabber.c -I/home/acciona/ffmpeg_build/include  -I/home/acciona/ffmpeg_build/lib -llibavutil -llibavformat -llibavcodec -lz -lm
<br>gcc -o ffmpeg_grabber ffmpeg_grabber.c -I/home/acciona/ffmpeg_build/include  "/home/acciona/ffmpeg_build/lib/libavutil.a" "/home/acciona/ffmpeg_build/lib/libavformat.a" "/home/acciona/ffmpeg_build/lib/libavcodec.a" -lz -lm
<br>gcc -o ffmpeg_grabber ffmpeg_grabber.c -I/home/acciona/ffmpeg_build/include  -L/home/acciona/ffmpeg_build/lib libavutil.a libavformat.a libavcodec.a -lz -lm
<br>Compiles but fail links:
<br>gcc -o ffmpeg_grabber ffmpeg_grabber.c -I/home/acciona/ffmpeg_build/include  -L/home/acciona/ffmpeg_build/lib -lavutil -lavformat -lavcodec -lz -lm
<br>gcc -Wall -g ffmpeg_grabber.c -o ffmpeg_grabber -I/home/acciona/ffmpeg_build/include  /home/acciona/ffmpeg_build/lib/libswscale.a   /home/acciona/ffmpeg_build/lib/libavdevice.a  /home/acciona/ffmpeg_build/lib/libavformat.a  /home/acciona/ffmpeg_build/lib/libavcodec.a   /home/acciona/ffmpeg_build/lib/libavutil.a   -lpthread  -lm -lz  -lmp3lame -lx264
<br>Linker errors (undefined a lot of things)
<br>gcc -Wall -g ffmpeg_grabber.c -o ffmpeg_grabber -I/home/acciona/ffmpeg_build/include  -L/home/acciona/ffmpeg_build/lib -lswscale   -lavdevice  -lavformat  -lavcodec   -lavutil   -lpthread  -lm -lz  -lmp3lame -lx264
<br> <br>Few link errors (not find av_*):
<br>gcc -o ffmpeg_grabber ffmpeg_grabber.c  -I/home/acciona/ffmpeg_build/include $(pkg-config --cflags --libs -L/home/acciona/ffmpeg_build/lib libavdevice libavformat libavcodec libavutil) -lpthread -lm -lz -lmp3lame -lx264
<br>gcc -o ffmpeg_grabber ffmpeg_grabber.c  -I/home/acciona/ffmpeg_build/include $(pkg-config --cflags --libs -L/home/acciona/ffmpeg_build/lib libswscale libavdevice libavformat libavcodec libavutil) -lpthread -lm -lz -lmp3lame -lx264
<br>gcc -I/home/acciona/ffmpeg_build/include $(pkg-config --cflags --libs -L/home/acciona/ffmpeg_build/lib libswscale libavdevice libavformat libavcodec libavutil) -lpthread -lm -lz -lmp3lame -lx264 -o ffmpeg_grabber ffmpeg_grabber.c
<br>gcc -I/home/acciona/ffmpeg_build/include $(pkg-config --cflags --libs libswscale libavdevice libavformat libavcodec libavutil -lpthread -lm -lz -lmp3lame -lx264 -o ffmpeg_grabber ffmpeg_grabber01.c
<br> <br>gcc  -lswscale -lavdevice -lavformat -lavcodec -lavutil -lpthread -lm -lz -lmp3lame -lx264 -o ffmpeg_grabber ffmpeg_grabber_01.c<br></div><div><br></div><br></div>