Getting LLVM and Clang from downloaded sources and Visual Studio 2013 - c++

I just downloaded the sources of LLVM and Clang as compressed files.
The files I have so far are:
cfe-3.5.0.src.tar
compiler-rt-3.5.0.src.tar
libcxx-3.5.0.src.tar
libcxxabi-3.5.0.src.tar
llvm-3.5.0.src.tar
I need to configure LLVM and Clang using Windows 8.1 using Visual Studio 2013.
I ask this question because the tutorials I have consulted so far uses svn, but having the sources from compressed files I not have a clear vision of what should be the directory tree in order to cmake work properly.

The directory structure should be:
llvm/
projects/
compiler-rt/
libcxx/
libcxxabi/
tools/
clang/
I'm not sure how far along libc++ support for Windows is, as I just use MSVC's implementation for ABI compatibility.

Compiling llvm framework (llvm, clang, libc++, etc...) with Visual Studio 2013 is not so dificult.
Download the sources
Descompress the sources
Move the decompressed folders to their place in the llvm source tree. (ex: cfe-version goes in llvm\tools directory with name clang. This king of info could be obtained from the CMakeFile.txt files (ex: add_llvm_external_project(clang) in the file `llvm\tools\CMakeFile.txt). The CMakeFile.txt are the files that instruct cmake program how to generate the projects (ex: Makefile, VS projects, XCode projects... for compile llvm)
Create a directory where to save the vs2013 projects
Generate the VS2013 projects (ex: being inside the previous directory execute: cmake llvm_sources -G "Visual Studio 12" where llvm_sources is the root directory of the llvm sources.
Open the project and compile (could take long to compile 30min or more)
Notes: some projects (ex: lldb) could need additional dependencies (ex: python c headers for bindings).
One of the problems of clang when compiling from sources is that the directory path of the include headers that clang use (ex: std library headers), are fixed in the source code in: llvm\tools\clang\lib\FrontEnd\InitHeaderSearch.cpp, in the case of compiling llvm with VS2013, by default it use the MS std headers.
Compiling almost every mid size program with clang using the MS header would give you error with MS extensions not supported yet by clang, with non-conforming c++ (that vc++ accept as valid) and other sort of problems, this is the case of various libraries of boost also (when using the MS headers).
Better success history for me was compile using this same procedure with MinGW for windows and using the MinGW headers. In this case most probably need to modify by hand the HeaderSearch file for clang to search for the header (the last versions of clang don't have search path for the last versions of gcc, at least in the stable version 3.5.0).
Using this method, I successfully compile clang 3.5.0 with MinGW with GCC 4.9.1 in Windows 8.1.

Related

Headers for Clang from VS build tools and LLVM

I was experimenting with different compilers, build managers and IDEs for my new project in C++. I am using VSCode(v1.52) on a windows 10 machine. I installed VS build tools 2019 and also included C++ Clang Compiler for Windows and C++ Clang-cl for v142 build tools (x64/x86). The project uses CMake as build manager and a plug-in CMake tools have been installed as well. Setup works fine as it is now.
However, I just want to know what are the differences to include Clang compiler from VSCode build tools 2019 and from LLVM. Does Clang that comes with VSCode build tools uses its own headers or the headers from VS? I do not want to use if Clang uses headers from VS..!
VSCode build tools (C++ Clang tools for Windows) will link the Clang compiler with Microsoft implementation of the Standard Library
Also, VSCode build tools has a component called: "C++ Clang-cl for v142" that gives you the freedom of using your own Compiler/Settings
Regarding header files, on Windows you should use clang with either GCC (Open Source) or MSVC header files.
I could not find the exact source of the header files in VS Build tools. However, as said above, it will link the compiler with Microsoft STL.
To install Clang with GCC header files (Works on VsCode):
go to https://www.msys2.org/ and install mysys2
then open mysys2 terminal and copy those commands to install Clang:
pacman -S mingw-w64-x86_64-clang
pacman -S mingw-w64-x86_64-clang-tools-extra
dont forget to add \msys64\mingw64\bin to the SYSTEM PATH variable
I have also made a video, with step by step: https://youtu.be/5OSO8IRlyXc

How to use clang for windows using mingw headers/libs

I downloaded the clang for windows binary package from the website. It provides some nice VS/MSBuild integration by allowing to build VS projects using clang instead of MSVC. However, I notice that it still uses the MSVC C Library and also the MSVC linker (link.exe). Also, including any C++ STL headers like string or iostream causes build errors.
My question is: Is it possible to use full clang/llvm toolchain along with some non-Microsoft libraries (like libc++, mingw etc.) to build a native Windows binary? Doing all of this from within VS is a bonus but even from command-line would be fine.

HDF5 Library error

I am using the follows
1) VS 2010 C++
2) Debug Win 32
3) The library from here
http://www.hdfgroup.org/HDF5/release/obtain5.html
Basically I downloaded Windows (32-bit) Compilers: CMake VS 2010 C, C++, IVF 12, RWDI and installed it. I tried to include a sample code in my C++ application and ran into the following
***HDF5 library version mismatched error***
The HDF5 header files used to compile this application do not match
the version used by the HDF5 library to which this application is linked.
Data corruption or segmentation faults may occur if the application continues.
This can happen when an application was compiled by one version of HDF5 but
linked with a different version of static or shared HDF5 library.
You should recompile the application or check your shared library related
settings such as 'LD_LIBRARY_PATH'.
You can, at your own risk, disable this warning by setting the environment
variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.
Setting it to 2 or higher will suppress the warning messages totally.
Headers are 1.8.12, library is 1.8.11
SUMMARY OF THE HDF5 CONFIGURATION
=================================
General Information:
-------------------
HDF5 Version: 1.8.11
Configured on:
Configured by: Visual Studio 9 2008
Configure mode: CMAKE 2.8.11.2
Host system: Windows-6.1
Uname information: Windows
Byte sex: little-endian
Libraries:
Installation point: J:/dev/opt/hdf5-1.8.11
You either have two versions of HDF5 installed and you are compiling with one (1.8.12) but linking with the other (1.8.11 in J:/dev/opt/hdf5-1.8.11), or more likely you installed HDF5, compiled your program, then updated HDF5 later on and didn't clean some object files in your project…
First try to Clean All and Build your program again, it might be enough.
If this doesn't work, find out if you have two versions installed at the same time and remove one of them if this is the case, Clean All and Build your program.
If this doesn't work, remove all HDF5 stuff on your system and reinstall the HDF5 library, Clean All and Build your program.
I have the same problem and I solved the issue by using
conda install -c anaconda hdf5=1.8.12
I hope this will work with you too
This seems to show up for only when the application(using Theano+Keras+Anaconda) is run using PyCharm in Windows machine.
You can, at your own risk, disable this warning by setting the environment
variable 'HDF5_DISABLE_VERSION_CHECK' to a value of '1'.
Setting the HDF5_DISABLE_VERSION_CHECK=1 suppresses it.

Mingw64 bit - what to do with this

I've downloaded source files for mingw.
Could someone please tell me what steps shall I make to build it on Windows7?
You have downloaded the sources to the MinGW-w64 CRT and headers.
You want the prebuilt toolchain binaries found in:
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/
There, you will find Personal builds by me (GCC 4.7 prerelease and 4.6) and sezero (GCC 4.4/4.5) in the form of zip or 7z archives you can unzip and use after adding mingw??/bin to your PATH.
You can also use the sometimes more updated autobuilds, but they're lacking some features.
Note there are also cross-compilers for Linux.

Installing C++ Boost library on Windows without Visual Studio

I would like to install Boost library without the need of Visual Studio compiler, preferably by downloading the pre-compiled binaries. We are working on a cross-platform C++ project in Eclipse, so VS is out of option.
About a year ago, I found an installer, but it does not longer exists.
The best match I have found so far is from:
http://www.boostpro.com/download/
but it seems like this one includes a lot of stuff related to VS.
If there is no installer available, is there an easy way of compiling it like the on *NIX platforms?
(I know that the majority of the library is header-only, but I would like some parts which are not)
Whichever toolchain that you are going to use on Windows, you can use that toolchain to compile Boost easily.
For example, if you use Eclipse CDT for C++ on Windows, you can use either MinGW or Cygwin toolchain. Then simply start the command prompt that has those toolchains (make, gcc, ...) in your path. Go to the Boost folder you downloaded. Run the bootstrap file to generate bjam. Then run bjam.
On a side note, if you want a cross-platform C++ project, you don't have to use a cross-platform IDE. You can use CMake as your build generator and then use any IDE you want.
One option is to get the full Boost source and then compile your own application to statically link in everything from Boost. If you manage to do this correctly, there will be no need to bundle the Boost binaries on any platform.