I've got some perfectly lovely C99 codes that are compiled from multiple .c files, and when I compile with Clang 2.7, I get some very strange errors:
/usr/include/bits/stdio.h:77: multiple definition of `putchar'
a2test.o:/usr/include/bits/stdio.h:77: first defined here
What's happening is that the GNU libc header file for <stdio.h>
declares certain functions, including putchar
, to be extern __inline__
, and for some reason clang is putting definitions into the .o
files. Then when the linker sees the duplicate definitions, it bleats.
I suspect a configuration problem: when I use the clang 2.7 that ships with Debian lenny, everything compiles. But for the class I'm teaching, software has to run on Red Hat Enterprise Linux 5, and my sysadmin has built clang 2.7 from source. (We're not using 2.9 because we couldn't get it to compile hello world, and we're not using a later version because we couldn't get the latest to build.)
I am looking for a workaround that will allow me to compile. Either a command-line option or a way to reconfigure clang so it doesn't do this bad thing.
I have already tried -U__USE_EXTERN_INLINES
with no effect.
LLVM bug 5960 shows that this problem results from an interaction between clang's C99 support and the old version of GNU libc that is installed on RHEL 5. It appears that for those of us stuck with RHEL 5, it's not possible to use clang -std=c99 -Ox
for any x > 0
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With