Compiling Cling with Visual Studio

Hi!
I am trying to build cling for Windows using Visual Studio. After all the steps were completed as shown below, I don’t seem to have the cling.exe in the directory /cling/build/Debug/bin for some reason. There’s a clang.exe, clang++.exe and a bunch of random llvm ones but it seems that only cling.exe is missing. Does anyone know if I am missing some steps or what went wrong?

// Install CMake 3.6.0 and Visual Studio Express 2015 for Windows desktop

git clone root.cern.ch/git/llvm.git src

cd src

git checkout cling-patches

cd tools

git clone root.cern.ch/git/cling.git

git clone root.cern.ch/git/clang.git

cd clang

git checkout cling-patches

cd …/…

mkdir build

cd build

cmake -DCMAKE_INSTALL_PREFIX=[Install Path] …\src -G “Visual Studio 14”

//Go inside build directory and open LLVM.sln, run “Build Solution” on “Debug” and “Win32”

Hi,

Cling doesn’t compile yet on Windows. Some changes are needed in cling itself, and in CMake as well…
We will make an announcement once it is supposed to work.

Cheers, Bertrand.

[quote=“bellenot”]Hi,

Cling doesn’t compile yet on Windows. Some changes are needed in cling itself, and in CMake as well…
We will make an announcement once it is supposed to work.

Cheers, Bertrand.[/quote]

Okay that makes sense. Do you have a rough estimate on when it will work for Windows?

Maybe next week, or the week after (if changes in CMake are working as expected)

Will the Windows builds appear in root.cern.ch/download/cling/?

Maybe, but if you want, you can already build the master version of cling with the master version of CMake…

The compilation works fine.
But when I run cling.exe, I am getting following error:

In file included from input_line_1:1:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\new:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\exception:7:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\type_traits:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\xstddef:6:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\cstddef:5:
In file included from C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\yvals.h:8:
C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\include\crtdefs.h:10:10: fatal error: ‘corecrt.h’ file not found
#include <corecrt.h>
^
Assertion failed: Pos != Map->end() && “no lookup entry for decl”, file D:\workspace\cling\src\tools\clang\lib\AST\DeclBase.cpp, line 1262

The error however disappears if I run cling.exe from Visual Studio Command Prompt.
There is $(UniversalCRT_IncludePath) missing somewhere.

Even when I run cling successfully I cannot do a very basic stuff like:

[cling]$ int i = 0; [cling]$ i IncrementalExecutor::executeFunction: symbol '?setValueNoAlloc@internal@runtime@cling@@YAXPAX00D_K@Z' unresolved while linking [cling interface function]! You are probably missing the definition of void __cdecl cling::runtime::internal::setValueNoAlloc(void *,void *,void *,char,unsigned __int64) Maybe you need to load the corresponding shared library?

Am I doing something wrong or Windows version is not matured enough?

Hi,

You’re right, it looks like some include path is missing in the command prompt… I will check.

It works for me:

[code]C:\Users\bellenot\build\llvm-test>Debug\bin\cling

****************** CLING ******************

  • Type C++ code and press enter to run it *
  •         Type .q to exit             *
    

[cling] int i = 0; [cling] i
(int) 0
[cling]$
[/code]
and even:

[code]C:\Users\bellenot\build\llvm-test>Debug\bin\cling

****************** CLING ******************

  • Type C++ code and press enter to run it *
  •         Type .q to exit             *
    

[cling] 12 (int) 12 [cling] #include
[cling] std::string s("abc"); [cling] &s
(std::string *) 00310008
[cling] s (std::string &) "abc" [cling] .q[/code]
It looks like you didn’t use the correct version of CMake… Could you tell me the result of cmake --version?
( I have “cmake version 3.6.20160727-g73c61”)

Cheers, Bertrand.

Hi Bertrand,

I was originally using cmake version 3.6.1
Now I switched to latest nightly build 3.6.20160727-ga1358 and it works.

The first error with missing header has not disappear, it still needs run from Visual Studio Command prompt.

But it is a good progress.

Cheers.
Michal

Hi again,

I am struggling to understand how do I link an external library with cling on Windows. On Linux it is working just fine using -I and -L switches.

I created a simplistic shared library called untitled on Windows. It contains only class declaration and constructor.

untitled.h

[code]class __declspec(dllexport) Untitled
{
public:
Untitled();

};[/code]

untitled.cpp

[code]#include “untitled.h”

Untitled::Untitled()
{

}[/code]

The class is compiled and untitled.dll and untitled.lib are created.
Now I am trying to link it like so:

[code]cling -ID:\workspace\untitled -LD:\workspace\untitled-build

****************** CLING ******************

  • Type C++ code and press enter to run it *
  •         Type .q to exit             *
    

[cling]$ .L untitled
[cling]$ #include <untitled.h>
[cling]$ Untitled u;
IncrementalExecutor::executeFunction: symbol ‘??0Untitled@@QEAA@XZ’ unresolved while linking function ‘_GLOBAL__sub_I_cling_module_2’!
You are probably missing the definition of public: __cdecl Untitled::Untitled(void) __ptr64
Maybe you need to load the corresponding shared library?[/code]

But the library is not loaded. What is wrong with my approach?

Hi,

No idea, that might well be that it doesn’t work. Since it build properly since only one week or so, that would not be very surprising… I’m still working on it, and there are still plenty of cling tests failing on Windows

Cheers, Bertrand.

Hi Michal,

Just a quick update to let you know that the “missing header” error has been fixed in git master.

Cheers, Bertrand.