CentOS 7 – stdatomic.h: No such file or directory

I got this error while installing Mplayer on Centos7.
This is the full error

libavutil/atomic.h:32:7: warning: "HAVE_ATOMICS_SUNCC" is not defined [-Wundef]
CC	libavutil/camellia.o
CC	libavutil/cast5.o
CC	libavutil/channel_layout.o
CC	libavutil/color_utils.o
CC	libavutil/cpu.o
libavutil/cpu.c:20:23: fatal error: stdatomic.h: No such file or directory
compilation terminated.
make[1]: *** [libavutil/cpu.o] Error 1
make[1]: Leaving directory `/root/mplayer/ffmpeg'
make: *** [ffmpeg/libavutil/libavutil.a] Error 2

Basically you have 2 options, 1/ upgrade gcc to 4.9 ( very long process ), or 2/ download stdatomic.h and add it into the package you’re installing. You definitely want to go with option no.2

Go here https://gist.github.com/nhatminhle/5181506 and download the file ( you get link in upper right corner – hit Raw button ).
And then look where is it used in the package you are installing

root@lj: mplayer# pwd

root@lj: mplayer# wget https://gist.githubusercontent.com/nhatminhle/5181506/raw/541482dbc61862bba8a156edaae57faa2995d791/stdatomic.h

root@lj: mplayer# find ./ -name "*.c" | xargs grep "stdatomic" -n
./ffmpeg/compat/atomics/pthread/stdatomic.c:27:#include "stdatomic.h"

Open stdatomic.c on line 27 and cpu.c on line 20 and make following change, from




That’s it – this is by far the easiest way to deal with this error.

Write a Comment