Quick Tip for Alpine Linux Docker Containers and the “C compiler cannot create executables” Error

Elliott
1 min readDec 7, 2024

--

With the latest release of Alpine 3.21.0, GCC has been upgraded to v14 and now certain warnings have been upgraded to errors. However, your autotools may not be very helpful, giving you messages like:

#9 [builder 4/5] RUN cd /thttpd   && ./configure || cat config.log   && make CCOPT='-O2 -s -static -fpermissive' thttpd
#9 0.051 creating cache ./config.cache
#9 0.057 checking host system type... Invalid configuration `x86_64-pc-linux-gnuoldld': machine `x86_64-pc' not recognized
#9 0.082
#9 0.082 checking target system type... Invalid configuration `x86_64-pc-linux-gnuoldld': machine `x86_64-pc' not recognized
#9 0.090
#9 0.091 checking build system type... Invalid configuration `x86_64-pc-linux-gnuoldld': machine `x86_64-pc' not recognized
#9 0.097
#9 0.098 checking for gcc... gcc
#9 0.099 checking whether the C compiler (gcc ) works... no
#9 0.113 configure: error: installation or configuration problem: C compiler cannot create executables.

On other distributions there’s a print statement to check config.log, but for whatever reason, it’s not there on this version, so you should add something to your dockerfile to cat this file if ./configure fails:

  && ./configure || cat config.log \

Now you will be able to see the compiler errors:

#9 0.140 thttpd.c:68:19: error: conflicting types for 'int64_t'; have 'long long int'
#9 0.140 68 | typedef long long int64_t;
#9 0.140 | ^~~~~~~
#9 0.140 In file included from /usr/include/sys/types.h:57,
#9 0.140 from thttpd.c:33:
#9 0.140 /usr/include/bits/alltypes.h:111:25: note: previous declaration of 'int64_t' with type 'int64_t' {aka 'long int'}

--

--

Elliott
Elliott

Written by Elliott

Personal interests in literature, SF, and whisky/whiskey/scotch, Software Engineer by Trade

No responses yet