Using -lpthread is deprecated. You must use -pthread and gcc will generate any parameters and libraries needed to support pthread.
As for others, their proper disposal is simply a matter of understanding the dependencies between them. If A depends on B , -lA should appear before -lB on the command line. In your case, -lm is a system mathematical library (which is separated only from the main libc for stupid causes of fatigue) and does not depend on anything else, so it should always be at the end of the command line. -lavutil is a library of utility functions used by ffmpeg and its included libraries, so it should appear after all other ffmpeg . -lswscale is an image scaling library that might be needed for other libraries, so I would put it after -lavformat and -lavcodec , but before -lavutil if it needs functions from -lavutil .
Finally, in the ffmpeg world, codecs are considered fundamental, and containers are considered a layer on top of them (rather, the opposite of some frameworks), so -lavformat depends on -lavcodec . So the final order in your example should be:
-lavformat -lavcodec -lswscale -lavutil -lm
And -pthread can go anywhere on the command line; it usually calls gcc to put the hidden -lpthread at the end, but can do different things as needed on different systems.
source share