ROOT 5.20 with Visual Studio 9.0

Hi,

most likely this is a very dumb question and is not really ROOT but Visual Studio 9.0 question, but I simply want to compile and link ROOT applications with the Visual Studio 9.0 IDE, but I’m somehow not able to figure out how to configure Visual Studio under Win XP to successfully do that.

What I did is adding the %ROOTSYS%\include to the include search path and %ROOTSYS%\lib to the library search path (at least I tried…)

So when e.g. trying to build a simple ‘project’ like

#include
#include “TRandom3.h”

using namespace std;

void main()
{
TRandom3 rand;
cout <<rand.Rndm()<<endl;
}

I already get an include error

c:\root\include\rconfig.h(480) : fatal error C1189: #error : Missing #include of %ROOTSYS%\include\w32pragma.h!

When I add an #include “w32pragma.h” (don’t know whether this is appropriate) I get some linker errors:

1>test1.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ““public: virtual __thiscall TRandom3::~TRandom3(void)” (??1TRandom3@@UAE@XZ)” in Funktion “_main”.
1>test1.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ““public: virtual double __thiscall TRandom3::Rndm(int)” (?Rndm@TRandom3@@UAENH@Z)” in Funktion “_main”.
1>test1.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ““public: __thiscall TRandom3::TRandom3(unsigned int)” (??0TRandom3@@QAE@I@Z)” in Funktion “_main”.
1>test1.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol ““public: __thiscall TVersionCheck::TVersionCheck(int)” (??0TVersionCheck@@QAE@H@Z)” in Funktion ““void __cdecl `dynamic initializer for ‘gVersionCheck’’(void)” (??__EgVersionCheck@@YAXXZ)”.
1>C:\Dokumente und Einstellungen\klausg\Eigene Dateien\Visual Studio 2008\Projects\test1\Debug\test1.exe : fatal error LNK1120: 4 nicht aufgelöste externe Verweise.

(Sorry for posting german error messages…)

I presume this is a very trivial error when knowing better about the VC++ IDE. Can anybody help me with this?

Best regards and thanks very much in advance,
Klaus

Hi Klaus,

You can force the include of w32pragma.h by adding -fIw32pragma.h flag in the makefile if you are using nmake makefiles, or in Visual Studio, in project properties -> C/C++ -> advanced -> Force Includes.

Then, for the linker errors, apparently you didn’t link with any of the Root libraries! You have to link with the Root libraries located in $ROOTSYS/lib (not necessary all of them, but that’s another story…)
Hope this helps.

Cheers, Bertrand.

Hi Bertrand,

thanks for your reply! But adding these libraries to the project actually seems to be the problem. I (obviously) found in the Project Properties -> Linker -> Input -> Additional Dependencies the place where to put the libraries names. Unfortunately there is no File Selector to add simply all root libraries (I dont want to put there every single library by hand). Is there a more simple way?
A related question is, how I can find out which ROOT object is located in which library (or better which libraries to link against for which ROOT object)

Is there an easy way to find out?

Cheers and thanks again,
Klaus

Hi Klaus,

Yes, open a command prompt, type “dir *.lib in $ROOTSYS/lib > libs.txt”, copy the list of libraries from editor to the Additional Dependencies field…

search the name of the class you want to use in $ROOTSYS/lib/*.rootmap

Cheers,
Bertrand.

Hi,

also the class reference documentation shows the library for each class, in the little window in the upper right corner.

Cheers, Axel.