Root on windows (Visual studio 2010)

Alright, I understand this part now. Unfortunatly, the console shows another error :confused:
I uploaded it :

The issue is about this TVirtual things or maybe the variable $ROOTSYS doesn’t exist here?

I noticed that the folder C:\root\etc\plugins\TVirtualStreamerInfo exists… so the issue is about the $ROOTSYS variable?

And what did you do to get this error?

I did this:

#include "TROOT.h"
#include "TCanvas.h"
#include "TFile.h"

using namespace std;

int main(int argc, char *argv[])
{
	TCanvas *canv = new TCanvas("c1", "", 200, 10, 1280, 720);
	TFile *file = new TFile("test.root", "RECREATE");
	file->WriteTObject(canv);

	system("pause");
	return 0;
}

Yes, it’s most probably because %ROOTSYS% is not defined in your environment…

Did I do it wrong?

No, it looks ok, how do you run the application?

I also check it as following:

Visual studio run the .exe for me when I click on the run button

Can you try to restart Visual Studio, to make sure the environment variables are known by it?

Still not but good idea! When I run the .exe from windows, it seems to work! I will do this I think

I can draw histograms now, thanks a lot for your help

1 Like

You’re very welcome

Cheers, Bertrand

After several reboots of root and visual studio, there is no error anymore. However Visual doesn’t create the test.root whereas I put a TFile process, I don’t know why but when I run the .exe from windows, it generates the test.root, nevermind.

(Maybe rights issue, I run Visual as admin but still not working)

Cheers, David

Check the file location, if Visual Studio starts the process in the C:\Program Files (x86)\... directory, it will definitively not work

Sorry but what file location do you mean? The project file.sln is in my Documents and the .exe generated is in my Documents too. However the Visual studio.exe is in Program Files

Okay you were right, I moved the project folder in Documents (instead of C:\projects) and I shaw the current folder with GetCurrentDir thanks to the second answer from “computinglife”

It turns out that the folder is …\myproject\myproject
As a result to have the same effect than running manualy the program from windows, I had to redefine the path in my C++:

TFile *file = new TFile("../Debug/test4.root", "RECREATE");

Everything is working well now… until the next time!

Cheers

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