How to incorporate Root libraries in VC++ 2008?

Dear Rooters,

I am using Root 5.20/00 on win32.

I am trying to incorporate Root libraries in a C++ software under XP with VC++ express 2008.
I get the following error message when building. I have added “/FIw32pragma.h” as an option in the Makefile.

1>------ Build started: Project: root_test, Configuration: Release Win32 ------
1>Compiling…
1>stdafx.cpp
1>Compiling…
1>root_test.cpp
1>Linking…
1>LINK : warning LNK4044: unrecognized option ‘/FIw32pragma.h’; ignored
1>root_test.obj : error LNK2001: unresolved external symbol “public: __thiscall TVersionCheck::TVersionCheck(int)” (??0TVersionCheck@@QAE@H@Z)
1>C:\Users\dehuu\Visual Studio 2008\Projects\root_test\Release\root_test.exe : fatal error LNK1120: 1 unresolved externals

Here is the source code:

// root_test.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
//For ROOT//////////////////////////////////////////////////////
#include "TROOT.h"
#include "TApplication.h"
////////////////////////////////////////////////////////////////

int _tmain(int argc, _TCHAR* argv[])
{
	
	return 0;
}

I am a new user of VC++ 2008 and would welcome an answer for beginners.
Thank you in advance,

Marc

Hi Marc,

This error is caused because “/FIw32pragma.h” it’s not an option for VC++.
To compile correctly this application you must have to:

  1. open Options->Projects and Solutions->Directory VC++ and add:
    a) the root’s bin location in the first list
    b) the root’s include directory in include files (combobox in the right)
    c) the root’s lib directory in lib files.

  2. Create a win32 console application, open the project options (configuration Release) and in the Linker->Input add manually in the first line the name of all root’s libraries that you will use. (you can add all)

  3. include in the first line of main.cpp #include “w32pragma.h” or if you want you can add all root’s includes in the stdafx.h but w32pragma.h must be the first.

If you have problems please write again!

Dear Lixo1,

Thank you for your answer. I understand most of it but don’t know how to enter the libraries in the Linker. Sounds a bit silly but I have never used VC++ before.

Regards,

Marc

Hi Marc,

To include the libraries you must open the project options, click in the Linker->Input tab. Click in the first line (additional dependencies) and paste it:
C:\root\lib\libASImage.lib
C:\root\lib\libASImageGui.lib
C:\root\lib\libCint.lib
C:\root\lib\libCore.lib
C:\root\lib\libMathCore.lib
C:\root\lib\libEG.lib
C:\root\lib\libEGPythia6.lib
C:\root\lib\libGed.lib
C:\root\lib\libGeom.lib
C:\root\lib\libGeomPainter.lib
C:\root\lib\libGpad.lib
C:\root\lib\libGraf.lib
C:\root\lib\libGraf3d.lib
C:\root\lib\libGui.lib
C:\root\lib\libHist.lib
C:\root\lib\libHistPainter.lib
C:\root\lib\libHtml.lib
C:\root\lib\libPhysics.lib
C:\root\lib\libPostscript.lib
C:\root\lib\libRGL.lib
C:\root\lib\libRint.lib
C:\root\lib\libTree.lib
C:\root\lib\libTreePlayer.lib
C:\root\lib\libTreeViewer.lib

Now you have all root’s libs in you project!
In attachment there is an example configured correctly (if root is installed in C:\root)

Cheers
Louis
RootForMarc.zip (687 KB)

Dear Louis,

Thank you very much. Your example is working fine.

Have a nice day,

Marc

Hi Marc,

It was a pleasure!!!
Cheers,
Lixo