mplayer 1.5 compilation failure -Wincompatible-pointer-types using GNU GCC 14 under Gentoo

Author:

main menu
note: expected const uint8_t const

Using GNU GCC to build the package mplayer 1.5 may result in an error during the compilation phase with the following output:

libvo/vo_aa.c: In function 'draw_frame':
libvo/vo_aa.c:360:17: error: passing argument 2 of 'sws_scale' from incompatible pointer type [-Wincompatible-pointer-types]
  360 |   sws_scale(sws,src,stride,0,src_height,image,image_stride);
      |                 ^~~
      |                 |
      |                 uint8_t ** {aka unsigned char **}
In file included from libvo/vo_aa.c:42:
/usr/include/libswscale/swscale.h:224:58: note: expected 'const uint8_t * const*' {aka 'const unsigned char * const*'} but argument is of type 'uint8_t **' {aka 'unsigned char **'}
  224 | int sws_scale(struct SwsContext *c, const uint8_t *const srcSlice[],
      |                                     ~~~~~~~~~~~~~~~~~~~~~^~~~~~~~~~
libvo/vo_aa.c: In function 'draw_slice':
libvo/vo_aa.c:380:17: error: passing argument 2 of 'sws_scale' from incompatible pointer type [-Wincompatible-pointer-types]
  380 |   sws_scale(sws,src,stride,y,h,image,image_stride);
      |                 ^~~
      |                 |
      |                 uint8_t ** {aka unsigned char **}

In version 14 if GNU GCC has been decided to throw an error by default (with standard >=C99) when there is a warning -Wincompatible-pointer-types. Some of the old software is not ready for such implementation, so using the older GNU GCC like version 13 or suppressing the error with CFLAGS=”-Wno-error=incompatible-pointer-types” should fix the error to warning and the compilation would not be interrupted.

Under Gentoo just switch back for this package to older GNU GCC with gcc-config tool:

srv ~ # gcc-config -l
 [1] x86_64-pc-linux-gnu-10.3.0
 [2] x86_64-pc-linux-gnu-11.3.0
 [3] x86_64-pc-linux-gnu-12
 [4] x86_64-pc-linux-gnu-13
 [5] x86_64-pc-linux-gnu-14 *
srv ~ # gcc-config x86_64-pc-linux-gnu-13
 * Switching native-compiler to x86_64-pc-linux-gnu-13 ...
>>> Regenerating /etc/ld.so.cache...

 * If you intend to use the gcc from the new profile in an already
 * running shell, please remember to do:

 *   . /etc/profile

srv ~ # . /etc/profile
srv ~ # emerge -v media-video/mplayer

List all available versions, select an older than 14 and reload the profile environments and then emerge the package. The compilation phase will only output a warning and package will be built and installed on the system.

If no older GNU GCC version is available just edit the CFLAGS to add “-Wno-error=incompatible-pointer-types” in /etc/portage/make.conf.

It is possible to tune the CFLAGS per a package by adding them before the emerge command, too:

srv ~ # CFLAGS="$CFLAGS -Wno-error=incompatible-pointer-types" emerge -v mplayer

The above line builds successfully the mplayer with GNU GCC 14, because it interprets the incompatible-pointer-types as a warning not error.
Check out a similar case – python 2.7 compilation failure -Wincompatible-pointer-types using GNU GCC 14 under Gentoo.

Leave a Reply

Your email address will not be published. Required fields are marked *