Vs2013 include root's .h compile error,with window7

I use vs2013 create a vc++ console project,and the cpp file such as:

#include "stdafx.h"

#include <TApplication.h>

#include <TF1.h>
#include <TRandom3.h>

int _tmain(int argc, char** argv)
	TApplication theApp("App", &argc, argv);

	TF1 *f1 = new TF1("f1", "sin(x)/x", 0, gRandom->Rndm() * 10);


	return 0;


I do this following this procedure:https://twiki.cern.ch/twiki/bin/view/Sandbox/ROOTandVisualStudio
,and errors are:

Error	7	error LNK2019: unresolved external symbol "public: __thiscall TVersionCheck::TVersionCheck(int)" () referenced in function "void __cdecl `dynamic initializer for 'gVersionCheck''(void)" (??__EgVersionCheck	C:\Users\win7\Downloads\rootDemoMy\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj	ConsoleApplication1

Error	6	error LNK2019: unresolved external symbol "public: static void * __cdecl TStorage::ObjectAlloc(unsigned int)" (?ge referenced in function "public: static void * __cdecl TObject::operator new(unsigned int)" ()	C:\Users\win7\Downloads\rootDemoMy\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj	ConsoleApplication1

Error	12	error LNK2019: unresolved external symbol "public: __thiscall TF1::TF1(char const *,char const *,double,double)" (?) referenced in function _wmain	C:\Users\win7\Downloads\rootDemoMy\ConsoleApplication1\ConsoleApplication1\ConsoleApplication1.obj	ConsoleApplication1

The root library is :root_v5.34.36

Please tell me how to solve it,thanks !

I don’t know where this TWiki page is coming from, but you have to link against ROOT libraries, at least libCore and libHist, and possibly others (check for missing symbols)

Thank you for your prompt answer. Is this TWiki page official? I want to generate .root format data for analysis in my vc ++ dll library. Is there a configuration method that I can refer to? I am a newbie using root and I am not familiar with the root library. I see that many questions are answered by you. Thank you.

As I said, I don’t know where it is coming from, but you can follow the instructions

It’s really application dependent, and it also depends on your skills with Visual Studio and programming in general… But I think if you try to follow the Twiki instructions you should be able to achieve what you want.

But first of all, do you really need to create your own application? You can also simply use ROOT macros. A good starting point is the ROOT User Guides and Manuals page. You can also look at the ROOT tutorials, and their explanation in the ROOT 5 Primer

Yes, I need to include the root lib library in my program and use the tree and branch to output .root files for others to use. Like you said, lib is not found, I add
#pragma comment (lib, “C: \ root_v5.34.36 \ lib \ libCore.lib”)
#pragma comment (lib, “C: \ root_v5.34.36 \ lib \ libHist.lib”)
#pragma comment (lib, “C: \ root_v5.34.36 \ lib \ libTMVA.lib”)
Compilation can pass, can view a curve now, thank you, I’m so glad

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.