ishani-logo
May 28th, 2012  »   »  50 Comments

I am maintaining a pre-built version of Clang for Windows, fetched from the head of SVN and built with Visual Studio – so no MinGW dependencies. Being fetched from the head means it isn’t ‘stable’, but it does let you muck about with the latest Clang features without fetching the source yourself – via ClangVSx, perhaps! – as well as experiment with any other extras I get around to adding into the distribution.

I track and update to the official Clang and LLVM source code via GitHub, as well as checking in any of my modifications.

OS Support: Both the October 2012 and Christmas 2012 drops are built using Visual Studio 2012 SP1 (Please snag the X86 redistributables from Microsoft to use it if you don’t have VS2012 installed) and they will not work on Windows XP. Otherwise, download the Visual Studio 2010 redistributables if you don’t have it installed.

ClangVSX Support: From the Christmas 2012 drop, you are downloading Clang 3.3; upgrade your ClangVSx installs to 0.4.5.

Clang isn’t completely ready for the terrors within the Windows Platform SDK but the latest version is at least at the stage where it can handle windows.h without detonating on the tarmac. It will still have occasional problems with the MS C++ Standard Library too. ClangVSx automatically fixes one other issue, which you may want to use if you’re running things from the command line:

  • Disabling use of _cxaa_atexit on Win32 builds; there is now code to properly use the ‘atexit’ approach (explained here, somewhat)

Other Stuff Bundled:

Drops since March 2013 also include the associated clang-c includes and export library for use with the precompiled libclang.dll.

The March 2013 release has added the include-what-you-use module back in, a Google project built on Clang that analyses and advises on the use of includes in C++ projects. To use it, just target the clang-IWYU.exe executable.

Download the most recent release (7zip, approx 8MB) here. This is built from source synced on 10th March 2013.

Previous versions:
clang3.3_jan2013.7z – synced 5th January 2013
clang3.3_xmas2012.7z – synced 4th December 2012 (no XP support)
clang3.2_oct2012.7z – synced 21st October 2012 (no XP support)
clang3.2_sept2012.7z – synced 2nd September 2012
clang3.2_aug2012.7z – synced 9th August 2012
clang3.2_may2012.7z – synced 12th May 2012

50 Comments...

50 Responses to Clang-Win32

    Michael Crump says:

    Any chance you have a patched version of the libclang.dll?

    ishani says:

    Hi Michael – libclang.dll is now included as part of the August release!

    Michael Crump says:

    Cool I think I’ll give it a try with vim clang completion

    littlewater says:

    Excellect Job! I tried to rebuild it and it worked fine in hello world !!

    but, it complained when I including with , maybe incompatible with VS’s header file?

    well… Is it possible to integrate as visual studio Platform Toolset ? Just as if switch between vc110 vc100 vc90 ??

    viki says:

    Awesome! thanks for your work.

    Dmitry says:

    Oh really, really thank you very much. You saved me so much time.
    I would be very cool if you keep your pre-built win32 binaries up-to-date.

    slimfast says:

    I would love to see an update! :-)

    ishani says:

    slimfast – your wish is granted :) .. I will endeavour to keep the package updated about once a month, work/life commitments allowing

    ishani says:

    littlewater – my longer term plan is for a more complete integration in VS for ClangVSx; as the Windows compatibility in Clang improves, we’ll see where the project goes…

    slimfast says:

    MANY THANKS for the new release!

    However, If I launch any of these executables I get an error “%1 is not a valid windows application.”. Am I missing something?

    ishani says:

    Did you install the VC++ 2012 runtimes (link at the top of the post) ?

    slimfast says:

    Sorry for the late reply, it took me a while to find out whats happening:
    I didn’t work with the redist as it fails to install. The simple reason: This is no longer compatible with WinXP, but requires at least WIn7 which I don’t have.

    The installer log states:
    [17A0:1768][2012-11-13T17:26:31]: Condition ‘VersionNT >= v6.1 OR (VersionNT = v6.0 AND ServicePackLevel >= 2)’ evaluates to false.
    [17A0:1768][2012-11-13T17:26:31]: Error 0x81f40001: Bundle condition evaluated to false: VersionNT >= v6.1 OR (VersionNT = v6.0 AND ServicePackLevel >= 2)

    So I have to stick with the old September version from now on. :-( Was there particular reason why you moved to MSVC 2012 and therefore cease support for Windows XP?

    ishani says:

    Sorry you’ve had troubles with it. I’m primarily using 2012 at the moment as it’s what I use at work, for the next build I’ll move back to 2010 so as not to cut XP users out of the loop.

    Dmitry says:

    ishani, thank you for your job, and please, could you rebuild latest clang with 2010? I can’t use current one because I have WinXP. It would be very nice.
    Have a good day!

    ishani says:

    Hey XP-ers; the Xmas2012 drop should sort you out, it’s built with 2012 SP1 (as jrb notes) which puts XP back on the map. Let me know if you are still having problems (don’t forget to get the latest redist package!)

    slimfast says:

    Works EXCELLENT again on all platforms I use. Thanks a bunch for such a nice x-mas gift! Just I have no idea how to put it under the tree… ;-)

    azsd says:

    VS2010 simple c++ project failed with clang3.3_xmas/3.2 package.

    Release mode, compile ok, linker failed.
    LLVM LTO Link :
    + G:\root\Projects\MyPrj\iOSHack\QMI\kyoumai\xxteatest\tmp\obj\Release\AddonFuncUnt.bc
    LTO-Linking failed.
    -o=”.\tmp\obj\Release\/__lto__.bc” “G:\root\Projects\MyPrj\iOSHack\QMI\kyoumai\xxteatest\tmp\obj\Release\AddonFuncUnt.bc”

    in debug mode, compile failed
    ——————————————————————————————————————————–
    Compiling :
    – AddonFuncUnt.cpp
    “G:\root\Projects\MyPrj\iOSHack\QMI\kyoumai\xxteatest\AddonFuncUnt.cpp” -c -nostdinc -D__CLANG_VSX__ -target i686-pc-win32 -std=c++11 -DUNICODE -D_UNICODE -DWIN32 -D_DEBUG -D_CONSOLE -D_MT -D_DLL -D_DEBUG -isystem “F:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include” -isystem “F:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include” -isystem “D:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include” -fms-compatibility -fms-extensions -fmsc-version=1600 -o”G:\root\Projects\MyPrj\iOSHack\QMI\kyoumai\xxteatest\tmp\obj\Debug\AddonFuncUnt.obj” -O0 -fno-inline -fdiagnostics-format=msvc

    UNREACHABLE executed!
    clang: error: clang frontend command failed with exit code 3 (use -v to see invocation)
    ——————————————————————————————————————————–

    – main.cpp
    “G:\root\Projects\MyPrj\iOSHack\QMI\kyoumai\xxteatest\main.cpp” -c -nostdinc -D__CLANG_VSX__ -target i686-pc-win32 -std=c++11 -DUNICODE -D_UNICODE -DWIN32 -D_DEBUG -D_CONSOLE -D_MT -D_DLL -D_DEBUG -isystem “F:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include” -isystem “F:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\atlmfc\include” -isystem “D:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\include” -fms-compatibility -fms-extensions -fmsc-version=1600 -o”G:\root\Projects\MyPrj\iOSHack\QMI\kyoumai\xxteatest\tmp\obj\Debug\main.obj” -O0 -fno-inline -fdiagnostics-format=msvc

    UNREACHABLE executed!
    clang: error: clang frontend command failed with exit code 3 (use -v to see invocation)
    ——————————————————————————————————————————–

    slim fast says:

    > ALSO: Updating to 2012 SP1 should restore the ability to run my distro on XP. If it does not, let me know.
    Nope – does not work. :-(

    > ALSO: The Christmas 2012 release moves us up to Clang 3.3; upgrade your ClangVSx installs to 0.4.5!
    This does not work in WinXP/32.

    I just figured out today. (I know I was reporting something different). The reason why it seemed to work for me was because I had an older version in the PATH before the X-Mas edition! So another Clang was in place the whole time! :-(

    Any help?

    ishani says:

    Turns out I was naive in my assumption that SP1 ‘just worked’ – of course, I was still using the vs110 toolchain instead of the magic vs110_xp .. perhaps it’s just me, but the way they have knackered XP support and hacked it back in with a whole separate toolchain is ugly.

    Anyway, I am moving back to building the install using VS2010 as 2012 clearly isn’t viable while anyone is still using XP in any significant fashion, I can’t be bothered with the hassle of having a whole extra ‘XP build’.

    New drop very soon (it’s compiling now)

    slim fast says:

    Great, I am looking forward to it. I am not using VS at all (I’m a MinGW/GCC guy), but this sounds really weird. However, its an interesting story anyways. Well XP will die definitely sooner or later but the PC I am working on is not scheduled for an update and its hardware is probably too old anyways. But the benefit is that I figure out such incompatibilities easily.. ;-)

    slimfast says:

    Hooooooray! Just to let you know it REALLY works now. I mean REALLY: I checked twice that i am really using the jan05 release and it works. Thanks a bunch and Happy new year! :-)

    Hey Ishani, thank you for this great project. I have a question, however. Why does clang++ have a noticeable delay in its usage? Typing “g++ –version” displays the results instantly, while typing “clang++ –version” needs 2-3 seconds. This also happens with compiling. Is this a Windows-only problem?

    ishani says:

    No delay here at all. What version of Windows are you using? Is it still slow on the second launch?

    I’m using Windows 8 x64. It’s always delayed.

    thomas says:

    thanks a ton..u saved a lot of time….

    Another question – why isn’t clang++ included? Or does clang work both as C and C++ compiler?

    ishani says:

    It’s identical to clang.exe – http://tinyurl.com/bejmap6. For your launch delay problem – what anti-virus do you use? 10MB might be a fair bit for it to scan each time, if indeed it is doing that. Are you running Clang from the Windows command line or from some other shell?

    I formatted yesterday, reinstalled Windows 8 x64, and the problem disappeared. It now works as it should, not sure what was causing the issue earlier. Thanks for the help

    I tried compiling a simple C++ file with your clang distro, but it complains about missing includes. I noticed it tries to find the header files in the Visual Studio folders. I, however, use MinGW. Is your clang distro only compatible with Visual Studio?

    ishani says:

    No, but given it was built with VS it will default to searching for those headers by default; Principally I use it with my ClangVSx add-in to test code from inside VS – which automatically configures system includes based on the loaded project. If you want to work in MinGW, go snag the MinGW binaries from the Clang site, they’re probably easier to set up in that environment.

    Trass3r says:

    Thanks a lot for this! At first I got bitten by http://llvm.org/bugs/show_bug.cgi?id=10606 but there is a workaround in the last comment.
    Any news on include-what-you-use?

    Trass3r says:

    Ok at least it’s able to preprocess things now.
    But compiling is still not possible. Since it masks itself as MSVC boost tries to use bugfeatures and other special stuff in typeof for example. I also hit the __debugbreak wall. And I think it also has its problems with Qt.

    blandcr says:

    hello:

    these binaries are excellent and work great.

    i ran into a small issue using them to build a vim plugin (YouCompleteMe) with msvc. it appears the libclang.dll is considered an “export” library and the ms linker cannot use that for “load time linking.” a corresponding “import” library (with .lib extension) is needed. luckily this can be accomplished with some dumpbin trickery on libclang.dll since the only symbols exported (and referenced in the used header files) are C but it’d be pretty slick if future releases could also include the import lib as well.

    ishani says:

    blandcr – you’re right, I have neglected to pop the export library in there too. Will do so for the next release.

    trisha says:

    thanks ishani for the pre-build binaries! I’m using your “libclang.dll” for python bindings. It works ok on 32-bit Windows 7; but on 64-bit, python bindings always prompt this error: “LibclangError: [Error 193] %1 is not a valid Win32 application” =( .I’ve already tried building my own binary of libclang.dll but still got stuck on this error.

    trisha says:

    opps.. the problem was not (probably) on libclang, but on python 64-bit ctypes module :-\
    http://sizeofvoid.blogspot.com/2012/05/ctypes-64-bit-windows-libclangdll.html

    anta40 says:

    Hi ishani,

    Please excuse my ignorance, but how can I compile a simple C++ code like this?

    #include

    int main(void){
    std::cout << "Hello world!" << std::endl;
    return 0;
    }

    I tried using your latest clang build (March 2013) within VS 2012 x86 Native Tools Command Prompt like this: clang hello.cpp

    And this is the error log
    http://pastebin.com/7CZ6kyDw

    Maybe I'm missing something here?
    I'm using 32-bit Win 7, BTW.

    martell says:

    hi ishani,

    I’m using cmake to generate my sln files but when I use your VSx plugin I get the following error.

    Could not recognize the MSBuild value ‘Disabled’ for property ‘InlineFunctionExpansion’ when converting to a VCProjectEngine legacy enumeration.

    Could this be skipped?
    I could provide a sample sln for you to have a look if your willing to do so?

    Many thanks
    Martell :)

    Thanks for building these. You may want to mention somewhere on the page that these are 32-bit builds.

    Hi,

    Big thanks for contributing clang build with VS!
    I have a few questions:
    Which branch(es) of clang-msvc and llvm-msvc do you exactly use to submit MSVC fixes?
    Can you make a quick Wiki page at GH with explanation how you build clang using VS?

    Do you also maintain MSVC port of include-what-you-use utility anywhere at GitHub?
    I’ve just tried the latest package and the IWYU is frequently crashing for me, so I’d be interested in building the toolset on my own so I can debug & test & make patches.

    Oktalist says:

    Excellent work. I’ve tried building from source with VS2010, and with MinGW, and tried the prebuilt binaries for MinGW, I’ve hacked the code, hacked the makefiles, fixed the dependencies, but nuthin’ doin’. Your ones just work.

    I’m using version 3.2 in order to use emscripten, which is not compatible with 3.3. But your 3.2 builds don’t include opt, which emscripten depends on. I don’t suppose there’s any chance you could rebuild 3.2 with opt.exe included?

    Oktalist says:

    Disregard the above, I got it to compile finally. Sorry to trouble you. Stay awesome.

    Borgleader says:

    I might have done something wrong here, but I have downloaded: “clang3.3_jan2013.7z – synced 5th January 2013″ and “ClangVSx-0.4.5.zip — Built version of 0.4.5 (2012-12-04) ready to drop into VS2010 or VS2012″. And I get compiler errors in type_traits:
    C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\include\type_traits(1072,32) : error: ‘_Ty’ does not refer to a value
    _HAS_TRIVIAL_MOVE_CONSTRUCTOR(_Ty)

    This is included by a lot of things (including, no pun intended iostream). Did I go wrong or is this normal? Thanks for all your efforts btw :)

    Marco says:

    Hi there,

    I’m trying ClangVsx on VS2010. I also installed the X86 VS2012 redistributables and I’m using your latest release of clang 3.3 (march 2013). With this simple code:

    #include

    int main()
    {
    std::vector vv;
    return 0;
    }

    I’m getting linker errors:

    main.obj : error LNK2019: unresolved external symbol __ZNSt7_LockitC1Ei referenced in function __ZNSt17_Container_base1211_Orphan_allEv
    main.obj : error LNK2019: unresolved external symbol __ZNSt7_LockitD1Ev referenced in function __ZNSt17_Container_base1211_Orphan_allEv
    main.obj : error LNK2019: unresolved external symbol __ZdlPv referenced in function __ZNSaISt16_Container_proxyE10deallocateEPS_j
    main.obj : error LNK2019: unresolved external symbol ___cxa_begin_catch referenced in function ___clang_call_terminate
    main.obj : error LNK2019: unresolved external symbol __ZSt9terminatev referenced in function ___clang_call_terminate
    main.obj : error LNK2019: unresolved external symbol __Znwj referenced in function __ZSt9_AllocateISt16_Container_proxyEPT_jS2_
    main.obj : error LNK2019: unresolved external symbol ___cxa_allocate_exception referenced in function __ZSt9_AllocateISt16_Container_proxyEPT_jS2_
    main.obj : error LNK2019: unresolved external symbol ___cxa_throw referenced in function __ZSt9_AllocateISt16_Container_proxyEPT_jS2_
    main.obj : error LNK2019: unresolved external symbol __ZNSt9exceptionD2Ev referenced in function __ZNSt9bad_allocD2Ev
    main.obj : error LNK2019: unresolved external symbol __ZNSt9exceptionC2ERKPKc referenced in function __ZNSt9bad_allocC2EPKc

    What am I missing?
    Thanks a lot!

    Marco
    main.obj : error LNK2001: unresolved external symbol __ZTVN10__cxxabiv120__si_class_type_infoE
    main.obj : error LNK2001: unresolved external symbol __ZTISt9exception
    main.obj : error LNK2001: unresolved external symbol __ZNKSt9exception4whatEv

    AR says:

    Hi,

    After performing steps of integration i am getting following issue

    Building Project : ProcessA
    Configuration : Release|Win32
    Project Directory : C:\Users\AR03\Documents\Visual Studio 2008\Projects\ProcessA\ProcessA
    Linker Output : C:\Users\AR03\Documents\Visual Studio 2008\Projects\ProcessA\Release\ProcessA.exe

    Custom Build Steps…

    ——————————————————————————————————————————–
    Compiling :
    – ProcessA.c
    C:\Users\AR03\Documents\Visual Studio 2008\Projects\ProcessA\ProcessA\ProcessA.c(10,33) : warning: format specifies type ‘unsigned int’ but the argument has type ‘unsigned int *’ [-Wformat]
    printf(“Address of Memory %x\n”,sharedPtr);
    ~~ ^~~~~~~~~
    1 warning generated.
    ——————————————————————————————————————————–

    Compilation Successful

    ——————————————————————————————————————————–
    Linking :

    LLVM LTO Link :
    + C:\Users\AR03\Documents\Visual Studio 2008\Projects\ProcessA\ProcessA\Release\ProcessA.bc [ok]

    LLVM LTO Code Generation …
    LTO-LLC failed.
    -stats -O3 -filetype=obj -o=”Release\/__lto__.obj” “Release\/__lto__.bc”
    llc.exe: Unknown command line argument ‘-stats’. Try: ‘C:\clang3.3_march2013\llc.exe -help’
    llc.exe: Did you mean ‘-load’?

    Thanks.

    mahdi says:

    Thanks so much

    George says:

    I’ve downloaded your latest Clang binary set (March 2013). I’m sure that I am unaware of something simple…

    I do not have Visual Studio at all, so I made sure to download the MS redistributables as instructed. I added the Clang folder to PATH. But I am unable to get even a simple ‘hello world’ C program to compile as the basic header files are not included (complaint is that stdio.h can not be found). Looking through the Clang folder tree I see that there are only a few .h files, not any for the standard library.

    Am I missing the point of where I am supposed to find the standard library modules? Or am I supposed to obtain them separately?

    Thank you very much for your work. I have needed to set up a Windows XP (32-bit) build server for Emscripten ports and it is such a pain to find clang 3.2 binaries for this.

    Your clang3.2_sept2012.7z package is perfect.

    Eleria says:

    Hi, thanks a lot for the clang compiles. Last time I tried to compile it I couldn’t get it to work.

Leave a Reply

Your email address will not be published. Required fields are marked *