Compile Cling on Visual Studio

I am trying to compile Cling on Visual Studio 2013.
There are a few compile errors here and there namely:

  • Use of inline namespaces
  • a few constexpr
  • cling::utils::platform::windows namespaces that needs to be fully specified when calling some functions
  • RegisterEHFrames and DeRegisterEHFrames use exception handling stuff not available in VS2013 on 32 bit build (looks like it’s 64 bit only stuff from MSDN).
  • Some of the /EXPORT: are leading to linking errors.

I have managed to compile somehow fixing these things and commenting the content of RegisterEHFrames and DeRegisterEHFrames but cling panics on a simple:


****************** CLING ******************
* Type C++ code and press enter to run it *
*             Type .q to exit             *
*******************************************
[cling]$ int i = 0; i
Assertion failed: !DD && Handlers.empty() && "Debug/EH info didn't get finalized
", file Z:\Desktop\cling\cling-build-windows\cling-src\lib\CodeGen\AsmPrinter\As
mPrinter.cpp, line 117
Wrote crash dump file "C:\Users\Stefano\AppData\Local\Temp\cling.exe-98abc4.dmp"

0x00D9C7F9 (0x00000016 0xD68F0FA8 0x0724CF00 0x0724CE14), HandleAbort() + 0x9 by
tes(s), z:\desktop\cling\cling-build-windows\cling-src\lib\support\windows\signa
ls.inc, line 404
0x5937F7F9 (0x00000016 0x00D9C7F0 0x0724CE00 0x59379AC4), raise() + 0x2B9 bytes(
s)
0x5938B284 (0x0724CF00 0x0724CE14 0x000000B7 0x088587F0), abort() + 0x34 bytes(s
)
0x59379AC4 (0x0563B168 0x0563B0A8 0x00000075 0x0724CE50), _wassert() + 0xD4 byte
s(s)

So my questions are:

  • Does Cling compile with Visual Studio ?
  • If yes, does Cling work with VS 2013 or does it need VS2015+ ?

Thanks

Hi,

[quote=“pagghiu, post:1, topic:24214”]

  • Does Cling compile with Visual Studio ?
    [/quote]Yes

You need at least Visual Studio 2015

Cheers, Bertrand.

Thanks a lot for the answer!

I have a few questions then:

  • The language / compiler issues look trivial to fix between VS2013 and VS2015 (few constexpr and inline namespace).
    I assume that the main differences are in the injected exception handling code and symbol exports (/EXPORT: mangled names in the linker command line).
    Where should I look then if for some reasons I would need to get this to compile under VS2013?

  • Has this been tested with the latest VS2017?

Thanks!

Hi,

I remember there were more issues than that. For example, VS 2013 doesn’t fully support the C++11/14(/17) standard. And sorry, I don’t remember all the other issues I had… (since the master compiles just fine with VS 2015 anyway)
And nope, it has not been tested with VS 2017 (not yet)

Cheers, Bertrand.

Ok, I will give VS2015 and VS2017 a shot and investigate the differences in the case I will not be able to update our compilers from VS2013 to more recent.

Thanks again for your answers.

You’re very welcome! But note also that Cling on Windows is not really stable, and it might not work as expected…
Cheers, Bertrand.

I’ve used cmake -G “Visual Studio 14” and “Visual Studio 15” in an attempt to get cling to compile using visual studio 2015 with update 3, and also with visual studio 2017, and am having no luck.

Is there a specific branch i should be using to get it to compile on windows10 with vs2015/17?

Hi,

Following the build instructions should be enough

Cheers, Bertrand.

Ahh yess. They are definitely easy instructions. It’s just that they don’t work :stuck_out_tongue:

Which is why i tried to modify the cmake command by explicitly stating which version of visual studio to use…

In all attempts (including following the directions explicitly, or using the cpt.py file from https://github.com/vgvassilev/cling) I get a 'identifier “PRUNTIME_FUNCTION” is undefined" from obj.clingUtils project in file PlatformWin.cpp line 752. my winnt.h should have PRUNTIME_FUNCTION defined, along with RUNTIME_FUNCTION, but the error persists. Is there a particular update of VS2015 I should be using instead of Update 3? The same error exists using vs2017 as well.

cling-src\tools\cling\lib\Interpreter\DeclUnloader.cpp(876): error C2660: ‘clang::CodeGenerator::forgetDecl’ : function does not take 2 arguments

Thanks

Edit: The windows directions should be updated to include the -G “Visual Studio 14 2015 Win64” argument to cmake. Doing so I was able to complete the cmake --build . step.

Thanks for your time.

Hi,

Yes, it’s what I was about to reply (sorry for the delay). Cling only builds in 64 bit mode for the time being. (It should be only temporary…)

Cheers, Bertrand.

Hi @bellenot,

Can we build 32 bit CLING for windows?

Actually, I followed the build instructions at https://root.cern.ch/cling-build-instructions URL to build CLING on my windows system and I have got a 64 bit windows CLING exe now.

But, my dependent DLLs(on which I need to work) are of 32 bit and hence am not able to load those DLLs in my cling interpreter. It throws error “cling::DynamicLibraryManager::loadLibrary(): LoadLibrary: returned 193: %1 is not a valid Win32 application”

So, is there a way to build 32 bit windows CLING or any build instructions link for the same?

Regards,
Prabhu

Try to specify -A Win32 when configuring cmake. E.g:

cmake -G "Visual Studio 17 2022" -A Win32 -Thost=x64 ..\src
1 Like

Thanks for the quick response @bellenot .
I will give it a try and update you ASAP

1 Like

Hi @bellenot,

I was able to build 32 bit CLING exe with -A win32 changes.

But when i try to load my .dll(32 bit dll) file, now I get the error “cling::DynamicLibraryManager::loadLibrary(): LoadLibrary: returned 126: The specified module could not be found.”

The steps I have followed are as below:

  1. Launched cling.exe from cmd prompt
  2. included all the header file paths needed for my DLL using .I option
    .I C:\Users\test\Documents\Prabhuraj\TSRF\mst_msvp\Code\MSVP\Base_Lib\CommonAPI
    .I C:\Users\test\Documents\Prabhuraj\TSRF\mst_msvp\Code\MSVP\Base_Lib\CoreLogger
    .I C:\Users\test\Documents\Prabhuraj\TSRF\mst_msvp\Code\MSVP\SAS_Lib\scwl
  3. .L C:\Users\test\Documents\Prabhuraj\TSRF\mst_msvp\Code\MSVP\R_SAS\SAS_scwl.dll

Step 3 throws the error above highlighted error.

Can you please let me know whats going wrong here?

Regards,
Prabhu

I don’t know. The only thing I can think of is to make sure the location of all your DLLs are in your PATH

1 Like

Would LoadLibrary() complain like that if any of the dependencies in the import table of the SAS_scwl.dll DLL cannot be found?

You might be able to find which those dependencies are with

dumpbin /dependents C:\Users\test\Documents\Prabhuraj\TSRF\mst_msvp\Code\MSVP\R_SAS\SAS_scwl.dll

As @bellenot mentioned, make sure that all those can be found in the library search path.

Cheers,
J.

2 Likes