Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

C++ program not compiling with Clang and visual Studio 2010 Express

I'm trying to compile the source code as described in this tutorial with visual c++ 2010 express. http://kevinaboos.wordpress.com/2013/07/23/clang-tutorial-part-ii-libtooling-example/

The full source code is over here. https://github.com/kevinaboos/LibToolingExample

I have used the executable provided in this link to install LLVM. I can't post the complete error message due to formatting issues. But I will try to give as much information as I can. When I'm trying to build the solution , I get the following errors :-

argument unused during compilation warnings.
C:\Program Files (x86)\LLVM\include\llvm/Support/Compiler.h(57,1): error : LLVM requires at least MSVC 2012.
C:\Program Files (x86)\Microsoft Visual Studio 10.0\VC\include\xlocnum(228,53): error : definition of dllimport static field not allowed
C:\Program Files (x86)\LLVM\include\llvm/ADT/IntrusiveRefCntPtr.h(26,9): fatal error : 'atomic' file not found

I'm using windows-7 64 bit. I've linked the header files and libraries by changing the project properties. I'm new to building c++ applications. Please help.

like image 983
Sourav Mukherjee Avatar asked Jun 13 '14 04:06

Sourav Mukherjee


People also ask

How do I run a Clang in Visual Studio?

To configure a Visual Studio project to use Clang, right-click on the project node in Solution Explorer and choose Properties. Typically, you should first choose All configurations at the top of the dialog. Then, under General > Platform Toolset, choose LLVM (clang-cl) and then OK.

Which C compiler does Visual Studio use?

CMake, Clang, mingw, and more Use MSBuild with the Microsoft Visual C++ compiler or a 3rd party toolset like CMake with Clang or mingw to build and debug your code right in the IDE.

Can you use GCC in Visual Studio?

Visual Studio's C++ Android development natively supports building your projects with the GCC that ships with the Android NDK, just like it does for Clang. You can also target Linux – either remotely or locally with the Windows Subsystem for Linux – with GCC. Compiler options for GCC.

Is Clang compatible with MSVC?

When Clang compiles C++ code for Windows, it attempts to be compatible with MSVC. There are multiple dimensions to compatibility. First, Clang attempts to be ABI-compatible, meaning that Clang-compiled code should be able to link against MSVC-compiled code successfully.


1 Answers

For MSVC 2012 build error, found a solution here

According to Clang documentation, Exceptions and SEH are not supported yet. You have to disable it.

To disable exception in Visual Studio, please open Project Properties and go to C/C++, Preprocessor, then add _HAS_EXCEPTIONS=0 to Preprocessor Definitions.

like image 183
sam Avatar answered Sep 28 '22 05:09

sam