Re: ROOT with Visual Studio 2008

From: Axel Naumann <Axel.Naumann_at_cern.ch>
Date: Mon, 11 Oct 2010 09:31:04 +0200


Hi,

we strongly recommend to use ACLiC, and we discourage using the bare compiler by not providing detailed tutorials for it :-) But you seem to already manage to build, so what exactly are you looking for?

You can get rid of the warnings by adding w32pragma.h as a forced include (somewhere in Project / C++ settings). This will silence most of the warnings that we silence in ROOT, too, and you get compatible build settings.

The only and most important ingredient to remember is that you need a debug build of ROOT if you build a debug application, and a release build of ROOT if you build a release application. Microsoft has different debug / release C runtimes and STL implementations; they must match across libraries.

Cheers, Axel.

yczhang_at_ihep.ac.cn wrote on 10/10/2010 08:54 AM:
> Hi, rooters:
> I want to use Windows ROOT with Visual Studio
> Now I have installed Windows ROOT and Visual Studio 2008 on Windows XP.
> In windows I set the environment variables as below:
> INCLUDE : C:\root\include; D:\Program Files\Microsoft Visual Studio 9.0\VC\ce\include
> LIB : C:\root\lib
> PATH : C:\root\bin
> ROOTSYS : C:\root
> And in Visual Studio 2008, I give these configurations:
> Project Property Pages:
> C/C++ ->Genernal ->Additional Include Directories : $(ROOTSYS)/include
> Linker ->Input ->Additional Dependencies : $(ROOTSYS)/lib/*.lib
> Ant then I write a ROOTProject.cpp file:
> #include "stdafx.h"
> #include <iostream>
> #include "TFile.h"
> using namespace std;
>
> int main(int argc, char* argv[])
> {
> TFile* fi = new TFile("output.root", "recreate");
> fi->Close;
> delete fi;
> cout<< "Hello ROOT!"<< endl;
> return 0;
> }
> But it appears as below:
> 1>Compiling...
> 1>ROOTProject.cpp
> 1>c:\root\include\tstring.h(455) : 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>d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(366) : see declaration of 'sprintf'
> 1>c:\root\include\tstring.h(458) : 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>d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(366) : see declaration of 'sprintf'
> 1>c:\root\include\tstring.h(473) : 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>d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(366) : see declaration of 'sprintf'
> 1>c:\root\include\tstring.h(479) : 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>d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(366) : see declaration of 'sprintf'
> 1>c:\root\include\tstring.h(482) : 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>d:\program files\microsoft visual studio 9.0\vc\include\stdio.h(366) : see declaration of 'sprintf'
> I do not know why there are so many warnings. But after my runnring the ROOTProject.exe, I indeed get a output.root file.
> I am not very familiar with VS2008, so is there a step-by-step user guide about using ROOT with VS2008
> I don't want to use CINT or ACLiC. I just want to use VS2008 to compile the codes with "#include "Txxx.h"" and generate a .exe file to finish my work. Is thers any tutorials about it?
> Thank you!
>
> --
> Best regards,
> ZhangYiChun
> Institute of High Energy Physics
> Yuquan street 19£¬ Shijingshan district, Beijing, China
> EMail: yczhang_at_ihep.ac.cn
>
>
Received on Mon Oct 11 2010 - 09:31:09 CEST

This archive was generated by hypermail 2.2.0 : Tue Oct 12 2010 - 17:50:01 CEST