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

Abhishek Kulkarni abbyzcool at gmail.com
Sun Dec 13 19:27:12 PST 2009


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)

The platform I'm building this on is x86_64 GNU/Linux.
FWIW, here is how the source files look:

$ cat hello.c
#include <stdio.h>
#include <stdlib.h>
#include <Block.h>
void hello(void)
{
        void (^a)(void) = ^{
                printf("Hello");
        };
        a();
}

$ cat world.c
#include <stdio.h>
#include <stdlib.h>
#include <Block.h>
void world(void)
{
        void (^a)(void) = ^{
                printf("world");
        };
        a();
}

The error disappears if I take off one or both instances of the
"#include <stdlib.h>"
line.

Is this a clang issue?

Thanks,
Abhishek



More information about the llvm-dev mailing list