I am having similar problems with chdir and freopen.
I will just post the steps I took to run googletest and run with VS2015 and Clang.
- Get LLVM snapshotbuild for windows. http://llvm.org/builds/
(Make sure you download the correct version (32- / 64-bit))
This will install the latest version of clang (at the time of writing v3.9). Keep in mind that this is a snapshot assembly, not an official version.
If you don't like snapshot builds, maybe try the latest version. I did not check. I just like modern tools, especially when they change quickly, like LLVM / Clang.
- After installation, you should get entries in the properties of the Visual Studio project.
Properties โ General โ Platform Tools โ LLVM-vs2014 (and more) (Switch to LLVM-vs2014 )
I know you are asking for Clang 3.7 with Microsoft CodeGen. You must decide for yourself.
In addition, I do not like to apply some corrections / changes to code that I did not write or do not know. Since this worked for me, I no longer explored the issue.
Now it can work for you. The following steps describe how to create googletest libraries and add include directories to your project.
Get googletest from github. https://github.com/google/googletest
Run cmake-gui and configure googletest to be able to create.
Generator: Visual Studio 14 2015 Win64 (I used only 64 bits, you can also try 32bit)
From llvm documentation
(no link because reputation is not enough: clang.llvm.org/docs/MSVCCompatibility.html):
First, Clang is trying to be ABI compatible, which means that Clang compilation code must be able to successfully compile code compiled using MSVC.
- Use custom compilers by default
Where is the source code: (e.g. C:\libs\googletest\googletest )
(Because the top directory also has googlemock)
Where to build binaries: (e.g. C:\libs\googletest\build )
- Uncheck the box:
BUILD_SHARED_LIBS (create shared libraries if you want) CMAKE_CONFIGURATION_TYPES : Debug and release (select others if you want)
Remember or change: CMAKE_INSTALL_PREFIX (e.g. C:\libs\googletest\install )
Python 2.7 was found by cmake, although I'm sure it is not necessary.
Click Customize and Generate.
After creating the solution file, go to the directory above (Where to build binary files, for example C:\libs\googletest\build ), and open the gtest.sln solution.
Select the Debug solution configuration and click on the ALL_BUILD and Build buttons. When done, right-click INSTALL and Build. This creates the folders specified earlier.
CMAKE_INSTALL_PREFIX (for example, C:\libs\googletest\install ) there you may want to change the name libs and add * d.lib so that the files are overwritten, and the debug assembly is used as a pointer.
Repeat the steps to configure the Release solution. In CMAKE_INSTALL_PREFIX (e.g. C:\libs\googletest\install ) you should find the include directory and the lib directory.
In your project, under Properties โ VC ++ Directories, add Include directories. CMAKE_INSTALL_PREFIX<b>\include</b> (e.g. C:\libs\googletest\install<b>\include</b> )
In your project, under Properties โ VC ++ Directories, add library directories. CMAKE_INSTALL_PREFIX \ lib (e.g. C: \ libs \ googletest \ install \ lib )
And under Properties Linker Input Additional Dependencies (gtest.lib / gtestd.lib depending on your configuration)
After that, I managed to create and run my tests.
source share