LNK2019 and LNK1120

Hello dear root community,

I have recently started working with root, but I have a lot of C++ experience. I searched the forum for simular problems, but they wern’t any solutions that solved my problem. I am trying to to Compile one of my Macros with the 64 bit cl.exe compiler but there are always linking errors (it compiles but doesn’t link). I am running the following command in the x64 Developer Command Prompt:

cl -std:c++17 -nologo -MD -GR -EHsc Compiling_test.cxx -I C:\root_v6.26.02\include /link -LIBPATH:C:\root_v6.26.02\lib libCore.lib libGpad.lib libHist.lib

I changed the file ending to .cxx, wrote a main function and included all the appropriate Header Files. (#include “TStopwatch.h” and #include “TRandom3.h”). I am very confident it’s not a problem of the source code. If i remove TRanddom3.h and its elemets it even works, but if I add more Headers i get more Linking errors, thus I conclude that my comand is missing the appropriate .lib files to include all that stuff. I looked at the folder but I just cannot figure out which files I have to include. Writing *.lib doesn’t work and I just get more errors.

The error is btw: Compiling_test.obj : error LNK2019: unresolved external symbol “public: __cdecl TRandom3::TRandom3(unsigned int)” (??0TRandom3@@QEAA@I@Z) referenced in function main
Compiling_test.exe : fatal error LNK1120: 1 unresolved externals

I would really appreciate some help :slight_smile:
with best regards

ROOT Version: root_v6.26.02 (64 bit)
Platform: Windows 10
Compiler: 64x cl.exe

Welcome to the ROOT Forum!
Add libMathCore.lib . See at the end of ROOT: TRandom3 Class Reference

1 Like


thank you for the quick anwser. I wasn’t aware, that there is a dependency table at the end of each header reference. Everything works now. Thank you very much!

with best regards,

1 Like