[LLVMdev] clang error: multiple definition of `gnu_dev_*'

Andrew Jeffery andrew at aj.id.au
Sun Dec 13 19:42:48 PST 2009


On 14/12/09 13:57, Abhishek Kulkarni wrote:
> When trying to link more than one object files compiled with clang, I run into
> errors of the following type:
>
> $ clang -fblocks -g -I$HOME/opt/include -L$HOME/opt/lib/ -o helloworld
> helloworld.c hello.o world.o -lBlocksRuntime
> world.o: In function `gnu_dev_major':
> /usr/include/sys/sysmacros.h:43: multiple definition of `gnu_dev_major'
> hello.o:/usr/include/sys/sysmacros.h:43: first defined here
> world.o: In function `gnu_dev_minor':
> /usr/include/sys/sysmacros.h:49: multiple definition of `gnu_dev_minor'
> hello.o:/usr/include/sys/sysmacros.h:49: first defined here
> world.o: In function `gnu_dev_makedev':
> /usr/include/sys/sysmacros.h:55: multiple definition of `gnu_dev_makedev'
> hello.o:/usr/include/sys/sysmacros.h:55: first defined here
> collect2: ld returned 1 exit status
> clang: error: linker command failed with exit code 1 (use -v to see invocation)
>

I've recently been playing around with using Clang as the system 
compiler on a Gentoo system and found several packages that did 
something similar. The fix appears to be to add the -std=c89 option; 
from memory Clang defaults to c99 (while GCC defaults to c89) and there 
is a difference in the handling of inlining functions. One instance of 
this was also fixed by compiling Clang/LLVM from SVN, so if the c89 
option doesn't fix it maybe give that a go (if you aren't already).

Hope that helps,

Andrew



More information about the llvm-dev mailing list