I faced similar problems with chdir and freopen.
I will just post the steps I took, to get googletest up and running with VS2015 and Clang.
- Get an LLVM snapshotbuild for windows.
http://llvm.org/builds/
(Make sure you download the correct version (32-/64-bit))
This will install a recent version of clang (at the time of writing v3.9). Be aware that this is a snapshot build and not an official release.
If you do not like snapshot builds, maybe try the latest release version. I did not test it. I just like to have up-to-date tools, especially when they are fast-paced like LLVM/Clang.
- After the installation you should get entries in the Visual Studio Project properties.
Properties
-> General
-> Platform Tools
-> LLVM-vs2014
(and more)
(Switch to LLVM-vs2014
)
I am aware that you are asking for Clang 3.7 with Microsoft CodeGen. You have to decide on your own.
In addition, I do not like to apply some fixes/changes to code I did not write or do not know. As this worked out fine for me, I did not investigate the problem any further.
At this point it might already work for you. The next steps describe building googletest libraries and adding the include directories to the project.
Get googletest from github.
https://github.com/google/googletest
Run cmake-gui and configure googletest to be able to build.
Generator: Visual Studio 14 2015 Win64 (I only used 64bit, you can also
try 32bit)
From the llvm documentation
(no link because not enough reputation: clang.llvm.org/docs/MSVCCompatibility.html):
First, Clang attempts to be ABI-compatible, meaning that Clang-compiled code should be able to link against MSVC-compiled code successfully.
- Use default native compilers
Where is the source code: (ex. C:\libs\googletest\googletest
)
(Because there is also googlemock in the top directory)
Where to build the binaries: (ex. C:\libs\googletest\build
)
- Uncheck:
BUILD_SHARED_LIBS
(build shared libs if you want)
CMAKE_CONFIGURATION_TYPES
: Debug and Release (choose others if you like)
Remember or change: CMAKE_INSTALL_PREFIX
(ex. C:\libs\googletest\install
)
Python 2.7 was found by cmake, even though im pretty sure it is not necessary.
Press Configure and Generate.
After generating the solution file, go to the directory specified above
(Where to build the binaries, ex. C:\libs\googletest\build
) and open the solution gtest.sln.
Choose Debug solution configuration and right click ALL_BUILD and Build.
When done, right click INSTALL and Build. This creates the folders specified earlier.
CMAKE_INSTALL_PREFIX
(ex. C:\libs\googletest\install
)
in there you may want to change the libs name and add a *d.lib to keep the files from overwriting and as designator that it was the debug build.
Repeat the steps for the Release solution configuration.
In CMAKE_INSTALL_PREFIX
(ex. C:\libs\googletest\install
) you should find an include directory and a lib directory.
In your project under Properties -> VC++ Directories add Include Directories.
CMAKE_INSTALL_PREFIX<b>\include</b>
(ex. C:\libs\googletest\install<b>\include</b>
)
In your project under Properties -> VC++ Directories add Library Directories.
CMAKE_INSTALL_PREFIX\lib (ex. C:\libs\googletest\install\lib)
And under Properties
-> Linker
-> Input
-> Additional Dependencies
(gtest.lib / gtestd.lib depending on your configuration)
After that I was able to build and run my tests.