I’m trying to use ROOT libraries in a very simple code, but I get a ton of errors. I’m on Windows 8, running VC++ 2010, and I’ve installed the VC++ 2010 MSI version of ROOT.
My code:
[code] #include
#include
#include
#include
#include “TLorentzVector.h”
using namespace std;
int main()
{
TLorentzVector muon1;
muon1.SetPtEtaPhiM(231.277,0.496237,-2.22082,0.1);
cout<<muon1.Px();
return 0;
}[/code]
Per another website’s suggestions, these are the steps I’ve done to link ROOT to VC++:
Property Pages>Config Properties>VC++ Directories>Library Directories: added $(root)\lib
Config Properties>C/C++>General>Additional Include Directories: added $(rootsys)\include
Config Properties>Linker>General>Additional Library Directories: added $(rootsys)\lib
Config Properties>Linker>Input>Additional Dependencies: included libPhysics.lib
error message in console:
1>------ Build started: Project: muonproject, Configuration: Debug Win32 ------
1> Source.cpp
1>c:\root\include\tstring.h(503): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(371) : see declaration of 'sprintf'
1>c:\root\include\tstring.h(506): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(371) : see declaration of 'sprintf'
1>c:\root\include\tstring.h(524): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(371) : see declaration of 'sprintf'
1>c:\root\include\tstring.h(535): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(371) : see declaration of 'sprintf'
1>c:\root\include\tstring.h(543): warning C4996: 'sprintf': This function or variable may be unsafe. Consider using sprintf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for details.
1> c:\program files (x86)\microsoft visual studio 10.0\vc\include\stdio.h(371) : see declaration of 'sprintf'
1>c:\root\include\tvector3.h(244): warning C4244: '=' : conversion from 'const Double_t' to 'Float_t', possible loss of data
1>c:\root\include\tvector3.h(245): warning C4244: '=' : conversion from 'const Double_t' to 'Float_t', possible loss of data
1>c:\root\include\tvector3.h(246): warning C4244: '=' : conversion from 'const Double_t' to 'Float_t', possible loss of data
1>c:\root\include\tlorentzvector.h(365): warning C4244: '=' : conversion from 'const Double_t' to 'Float_t', possible loss of data
1>Source.obj : error LNK2019: unresolved external symbol "public: __thiscall TVersionCheck::TVersionCheck(int)" (??0TVersionCheck@@QAE@H@Z) referenced in function "void __cdecl `dynamic initializer for 'gVersionCheck''(void)" (??__EgVersionCheck@@YAXXZ)
1>C:\Users\Jeffrey\documents\visual studio 2010\Projects\muonproject\Debug\muonproject.exe : fatal error LNK1120: 1 unresolved externals
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
Apparently using W32Pragma.h or something gets rid of a lot of these errors? I’m just trying to figure out why my code won’t run, as it’s simple enough. Also, I get this error message in the console: imgur.com/XGsnPQB
Thanks for the help guys, I really can’t find any other solutions online. Also, I’m a huge C++ noob if that wasn’t already apparent.