Using clang directly from the binary download

Hi

I would like to try clang. My only requirement is to build a few C++ programs.

There is a binary download for clang on the clang downloads page (in the section "Pre-built Binaries"), with the text "Clang for Windows 64-bit (sig)", but the file it downloads is LLVM-3.8.0-win64.exe, (for Windows 64-bit). This seems to be the LLVM backend.

How can I use this file to build a C++ program? Can I use it directly or do I need to go through the "frontend" (clang)? There is no separate option or file named "clang" in the binary download.

Thanks
Steven
Last edited on
LLVM-3.8.0-win64.exe is the installer. Run he installer to install clang++-3.8.
Opt to add LLVM to the path, and after installation, from the command prompt type clang++ --version
and you should see something like:
clang version 3.8.0 (branches/release_38)
Target: x86_64-pc-windows-msvc
Thread model: posix
InstalledDir: C:\Program Files\LLVM\bin



This is another option, if you already have (or intend to install) Visual Studio 2015
( Community Edition: https://www.visualstudio.com/en-us/products/visual-studio-community-vs.aspx )

From the Visual Studio menu,
choose File | New | Project | C++ | Cross Platform | Install Clang with Microsoft Codegen.
This will download and install the clang++ front-end.
Once the front-end is installed, you can cancel the creation of the Cross Platform project.

Now, create a normal Windows C++ Project: File | New | Project | C++ | Win32 Console Application
After the project is created, to use the clang++ front-end, from the menu, choose Project | Properties
In the property pages Dialog, choose Configuration Properties | General (left pane)
and Platform Toolset | Clang 3.8 with Microsoft Codegen (right pane, choose from list)
Thanks for this input. It has worked successfully.

However, I have written a makefile to build a "Hello World" program. The build starts, but clang gives a fatal error at the line:

 
#include <iostream> 


The error is:


'iostream' file not found


I have searched in the clang install directory's subdirectories. There are several .h files, but iostream is not there.

Thanks
I find that none of the expected h files are to be found. eg: <vector>, <map>, etc.

I am on Windows.

I am accessing the make system through MSYS, which I had earlier downloaded along with minGW.

minGW and g++ work fine, but I am unable (so far) to get clang to work.
The standard LLVM builds for clang++ on Windows (for instance LLVM-3.8.0-win64.exe) requires that he Microsoft implementation of the standard library and headers (at least Visual Studio 2013 Express IIRC) is installed. It does not look for, and will not use either MinGW/MSYS or the GNU libraries.

And then use a command line like:
clang-cl -Xclang -fms-compatibility-version=19 -Xclang -std=c++14 -Xclang -Wall  -Xclang -Wextra -Xclang pedantic-errors myfile.cpp
clang-cl - compiler driver that establishes Microsoft compatibility
-Xclang - the following option is to be passed verbatim to the clang++ compiler
-fms-compatibility-version=19 - the version of Microsoft C++ that clang++ should target.
Here, =19 is an example - the Microsoft C++ version 19 (the one shipped with Visual Studio 2015, and has C++14 support)
Is it possible to have a "non-standard" LLVM build in which LLVM can be installed with its _own_ standard library and headers?

Thanks.
> Is it possible to have a "non-standard" LLVM build in which LLVM can be installed
> with its _own_ standard library and headers?

Currently, this is possible only on the BSD family of operating systems.

On linux, there is an implementation of clang++/libc++, but it has a few dependencies on the GNU libsupc++

On Windows, there is no current implementation of LLVM libc++.

I have downloaded the following package from MS and installed it successfully: vc_redist.x64. However, the same problem occurs when building a program using clang. I thought this download was the MS C++ standard library.

Perhaps the entire MS VC++ download needs to be done and that's a big download running into GB.

Thanks.
> Perhaps the entire MS VC++ download needs to be done

Yes. vc_redist.x64 contains only the compiled library binaries; it does not have headers and build tools.

> big download running into GB

For a much smaller download size, and easy installation, Cygwin http://cygwin.com/
and its clang package https://cygwin.com/cgi-bin2/package-grep.cgi?grep=clang-3.7&arch=x86_64
(You don't need the src package, unless you want to build clang from source. Version is 3.7, not 3.8)
Last edited on
Thanks for this tip.

I have now done the following:
1) I have installed cygwin on my PC.
2) Since the package you identified was for clang 3.7.1, I uninstalled clang 3.8 from my PC and installed the clang 3.7.1 binary instead.

Clicking on the link provided by you: https://cygwin.com/cgi-bin2/package-grep.cgi?grep=clang-3.7&arch=x86_64 takes me to the cygwin page where I can see the package details, but not _install_ the package. Do I need to go to the clang website for the installation? I checked this out, but it appears I need to download the clang source and build it.

Alternatively perhaps I'm missing something here.

Thanks.
Alternatively perhaps I'm missing something here.


If you visit https://cygwin.com/install.html which is one of the links listed on the top left of the page linked to by JLBorges, you'll learn how to install cygwin and its various packages.
Topic archived. No new replies allowed.