linker error on mingw

Hi all,
I am new for clang and llvm and this mailing forum. I am trying build cland on my windows xp 32 bit system using “cland binaries for mingw32 version 2.9” and “llvm binaries for mingw32 version 2.9”. I follow following steps:

  1. download mingw in directory (C:/MinGW)
  2. download “clang2.9 binaries for mingw32” and “llvm-2.9 binaries for mingw32”
  3. extract both in the same directory of mingw (C:/MinGW)
  4. set path C:/MinGW/bin to PATH environment.
    Then I write one simple code
    #include<stdio.h>
    int main()
    {
    printf(“hello world\n”);
    return 0;
    }

then compile code
clang hello.cpp -o hello.exe
it compiles fine
but when I tried to execute it
clang hello.exe
it gives following error

ERROR

hello.exe:crt1.c:(.text+0x280): multiple definition of mainCRTStartup' c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../crt2.o:crt1.c:(.text+0x280): firs t defined here hello.exe:crt1.c:(.text+0x2a0): multiple definition of WinMainCRTStartup’
c:/mingw/bin/…/lib/gcc/mingw32/4.6.2/…/…/…/crt2.o:crt1.c:(.text+0x2a0): firs
t defined here
hello.exe:crt1.c:(.text+0x2c0): multiple definition of atexit' c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../crt2.o:crt1.c:(.text+0x2c0): firs t defined here hello.exe:crt1.c:(.text+0x2d0): multiple definition of _onexit’
c:/mingw/bin/…/lib/gcc/mingw32/4.6.2/…/…/…/crt2.o:crt1.c:(.text+0x2d0): firs
t defined here
hello.exe:cygming-crtbegin.c:(.text+0x2e0): multiple definition of __gcc_regist er_frame' c:/mingw/bin/../lib/gcc/mingw32/4.6.2/crtbegin.o:cygming-crtbegin.c:(.text+0x0): first defined here hello.exe:cygming-crtbegin.c:(.text+0x36c): multiple definition of __gcc_deregi
ster_frame’
c:/mingw/bin/…/lib/gcc/mingw32/4.6.2/crtbegin.o:cygming-crtbegin.c:(.text+0x8c)
: first defined here
hello.exe:crt1.c:(.bss+0x4): multiple definition of _argc' c:/mingw/bin/../lib/gcc/mingw32/4.6.2/../../../crt2.o:crt1.c:(.bss+0x4): first d efined here hello.exe:crt1.c:(.bss+0x0): multiple definition of _argv’
c:/mingw/bin/…/lib/gcc/mingw32/4.6.2/…/…/…/crt2.o:crt1.c:(.bss+0x0): first d
efined here
c:/mingw/bin/…/lib/gcc/mingw32/4.6.2/crtbegin.o:cygming-crtbegin.c:(.text+0x85)
: undefined reference to `_Jv_RegisterClasses’
collect2: ld returned 1 exit status
clang: error:
linker
(via
gcc)
command
failed
with
exit
code
1
(use
-v
to
see
invocation)

*****************************************************]
How can I resolve this problem?

I'm not sure about the exact problem, but please note that 2.9 release
is very old. Unfortunately there are no official binaries for 3.0
release. I would recommend that you build clang from the source (it's
not very hard, ask for help if you run into problems) or you could try
one of the personal builds from Ruben Van Boxem at
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win32/Personal%20Builds/rubenvb/4.7.0-3/

Well here's your problem! Clang is a compiler (and a compiler/linker driver); you don't need it to run the program. So, try not sticking 'clang' in front. Try just:

hello

(or:

./hello.exe

if you're using MSYS bash).

Chip