Issues compiling ROOT for c++ & Visual Studio


Please read tips for efficient and successful posting and posting code

Please fill also the fields below. Note that root -b -q will tell you this info, and starting from 6.28/06 upwards, you can call .forum bug from the ROOT prompt to pre-populate a topic.

_ROOT Version:6.30.04
_Platform:Windows 11
_Compiler:Visual C++


Dear Rooters,
my motivation compiling ROOT was obviously to cisrcumvent the stringent requirement for using the exact toolset that was used to compile the distibuted ROOT binaries.

At some point I decided to bite the bullet and attempt to compile the latest version of root using the provided instructions on the main website.

My objective was to build a basic root before attempting to add any optional components.

So I installed the latest version of git and downloaded the latest version of Python (just in case).

I followed the instructions and asmazingly after about an hour the root build finished pretty much successfully with only one error repeated 5 times, that it could not find some iconvXXX.h. I was hoping this wouldn’t matter as over 100 libraries were built and all the bibaries seemed to be there. root 6 commad prompt starts successfully, so in principle the tructure was largely there.

So I tried compiling a simple code using the VS c++ interface. I had a recomendation at a previous time point to use cmake rather than the VS gui. I thought since I compiled root from scratch to re-attempt to use my familiar interface before going to cmake.

In any case the problem I run to doesn’t seem related that aspect.

My code went through the compilation step successfully but then got stuck at the linker.

The linker kept complaining that it cannot access input file cppyy3_8.lib. This file was not in the dependencies list I had pasted in the gui.

It was also not in the lib folder of root.

Then I searched my compute and found copy in a precompiled version of root6. I knew this would likely lead to new problems, but I thought I’d try to copy over that lib file to the lib directory of the root version i had compiled. Then the compiled asked for another lib file that was not in the lib directory. So I kept pasting in the files from the other root installation, just to see where this is going. In the end I had to paste in around 5 missing lib files before the linker started complaing about unresolved externals, which I assume had to do with the pasted lib files that were from another version or root.

The question is, why are there missing library files from the root version I compiled, despite there not being any errors related to those libraries (or so I thought)?

And secondly why is the linker trying to pull in libraries related to Python?

This is not completely true, you can use a pre-built binary and use it with another version of Visual Studio. Microsoft made the binaries compatible.

Well, if there is an error, it might well be that some parts will be missing…

This has nothing to do with the way ROOT was built. It’s simply the simplest way to produce compatible builds between the ROOT compiler flags and your application compiler flags that should be the same.

So this looks weird. It’s the sign of a mixing old (or previously installed) version of ROOT, built with Python 3.8, and the one you built.

You should first make sure to clean-up your environment, without any other version of ROOT, and if you decide to build yourself, check for error messages, there shouldn’t be any.

It shouldn’t. And you can still disable PyROOT if you don’t need it.

Hello Bellenot,

  1. I followed the instructions in the main ROOT page to the dot. And what I mean by that, I litterally did copy paste of the commands from the screen. I even used the same folder names. I guess the fact that it was building for an hour is indicative that the bulk of the operation was conducted correctly. Of course I know that something is not right, otherwise i would not be here asking.

  2. I checked the section pre-requisites. It did not say that I need git for example, but without git the build was finishing in 30 seconds with hundreds of errors. The fact that git is not mentioned as a prerequisite, made me think that there may be other pre-requisites that are perhaps considered obvious. So i would have to figure out what is obvious.

  3. You say that I should clean up my environment. Which part of the environment? The instructions do not mention for example required values for environment variables. Are there any such requirements? Do I need to add anything to the PATH variable? None of these is mentioned in the instructions.

  4. at the end of the root build there was only one error repeated 5 times about a missing iconvXXX.h file. I was hoping that this might give a hint as to what went wrong with my compilation.

  5. Assuming successful root build, is there any way to not select python related lib files when pasting them in the linker input list (when building my own code)? I had the suspicion that one of the libraries I included was python related and it was then trying to pull in other python libraries. Is this something i should worry about?

I would appreciate -if possible- exact answers in the above questions. Then I can try re-building it and make sure subsequently that I do not accidentally include and python libraries in the linker list.

Git is not needed if you download the binaries or if you build from a source tar file. It is only required if you want to build from a git repository, which seems obvious enough to me…

I mean, since it looks like you already have another version of ROOT installed somewhere, make sure it doesn’t interfere with the version you want to build. And no, you don’t need to add anything in the environment variables, except if you want some specific packages, but just forget that for the time being

Can’t you attach the log of the build with the exact error messages? It s would be much simpler and this will save some of our time

Two options: Either you build without pyroot, as I already said, or you select only the libraries you really need. You can also use root-config --libs for a list of most commonly used libraries or root-config --glibs for the ones including the GUI:

C:\root-dev\rootdev>root-config --libs
/link -LIBPATH:C:\root-dev\build\x64\release\lib libCore.lib libImt.lib libRIO.lib libNet.lib libHist.lib libGraf.lib libGraf3d.lib libGpad.lib libROOTVecOps.lib libTree.lib libTreePlayer.lib libRint.lib libPostscript.lib libMatrix.lib libPhysics.lib libMathCore.lib libThread.lib
C:\root-dev\rootdev>root-config --glibs
/link -LIBPATH:C:\root-dev\build\x64\release\lib libCore.lib libImt.lib libRIO.lib libNet.lib libHist.lib libGraf.lib libGraf3d.lib libGpad.lib libROOTVecOps.lib libTree.lib libTreePlayer.lib libRint.lib libPostscript.lib libMatrix.lib libPhysics.lib libMathCore.lib libThread.lib libGui.lib
C:\root-dev\rootdev>root-config --libs
C:\root-dev\rootdev>

Copying and pasting blindly all the libraries is anyway not a good practice.
I hope my answers are clear enough, otherwise just let me know. And again, attaching a capture of what you do and the output would help.
And BTW, why didn’t you take a pre-built binary?

Ι mean, since it looks like you already have another version of ROOT installed somewhere, make sure it doesn’t interfere with the version you want to build. And no, you don’t need to add anything in the environment variables, except if you want some specific packages, but just forget that for the time being

I am trying to establish how the other ROOT version can “interfere”. Only via ROOTSYS environment variable. But I assume this does not do anything to the ROOT build right? Otherwise all the build steps I mentioned happened in a totally separate folder tree no where near any other root version. So if no other pre-requisites are needed, if no environmental variables need to be set, and since I just copied and pasted the same commands as in the root tutorial, I don’t see why there would be any problems with the build. I wish I had output the stdout to a log but I didn’t so I need to rebuild it to get the log. I was hoping to get some hints before doing so.

Two options: Either you build without pyroot, as I already said, or you select only the libraries you really need. You can also use root-config --libs for a list of most commonly used libraries or root-config --glibs for the ones including the GUI:

Ok I will try one of those. My problem is that I do not know any good method to select the “libraries I need”. I was looking online for such methods and the best advice I saw was “guess”. Well obviously I guessed wrong:)

Ok thanks for the advice, I have some things to try out now, I will report back if I succeed or need any more advice.