How to build a standalone ROOT application?

I am trying to code a ROOT application under the visual studio c++ environment. It is possible for me to run the code in the computer which has installed ROOT. However, the application cannot be run in another computer without ROOT is installed. The error msg. is about missing libcore.dll.

So my question is, how to build an application in VC, that can run in another computer without ROOT installation?

Is it required to CMake the Root source and turn it into a single static library?

Thanks
J

Hi,

There is actually no option to statically build ROOT on Windows. I don’t know what would be required in CMake to enable this feature. We’ll keep you in touch.

Cheers, Bertrand.

thanks Bertrand,

Then is it implies that we must install Root into computers that required to run a root application?

Thanks,
J

Yes, exactly.

Cheers, Bertrand.

While apparently not supported by ROOT-team, running a VC-build standalone application that uses ROOT does not require ROOT to be installed in the system that runs the app. There are some pitfalls and making it work requires trickery, but it can be done. It includes for example distributing ROOT DLL’s and some other stuff in the ROOT installation in addition to manual handling of ROOT-related environment variables such as ROOTSYS.

What comes to idea of using statically linked ROOT, correct if I’m wrong, but using static linking imposes GPL-restrictions on the application that won’t appear in case of dynamic linking. Perhaps not a problem for many, but just mentioning this to get a better picture of the issue.

Thanks tc3t

I have tried to config the Project Properties by setting the include directories, and library directories. However, it can be successfully build under the release mode, while got error in debug mode…

Error 1 error LNK2019: unresolved external symbol “public: static void __cdecl TObject::operator delete(void *)” (??3TObject@@SAXPAX@Z) referenced in function __unwindfunclet$?test@@YANXZ$0

Error 14 error LNK1120: 13 unresolved externals

J

Do you remember that … if you want to debug your code, you need the debug version of ROOT for Windows (you cannot mix release / debug builds due to a Microsoft restriction).

I had a quick look on how to build ROOT static libraries with CMake. This should be fairly easy for any platform except for Windows. This is because for Windows there are some additional steps that now need to be adapted. I’ll continue to look at it at somehow low priority.

Pere

thanks Mato and Wile

Then it is possible to create a single ROOT dll which can be called independently by any standalone application, under OSX or Linux environment and compiling with g++?

Thanks,
J

I don’t really understand what your question is.

If you ask whether it is possible to mix libraries created on MacOS with another ones created on Linux, then I say no, it is not (i.e. never). Libraries (and any object code files) are “operating-system specific”.

However, if you ask whether, while working on a particular system (either MacOS or Linux), it is possible to mix object code (from some libraries or from your own application) which contains debugging information with another object code (again from some libraries or from your own application) which does not contain debugging information, then I say yes, it is possible.
So, you can use ROOT libraries which do not contain debugging information with your own code compiled so that it does contain debugging information (and vice versa, of course).

There is one additional point. Typically, object code produced by one version of g++ is NOT binary compatible with object code produced by another version of g++ (and it is NOT binary compatible with object code produced by another available C++ compilers). That means that, in general, you MUST use the same compiler (e.g. “root-config --cxx”) and some important compiler and linker flags (e.g. “root-config --cflags” and “root-config --ldflags”) to compile and link your own application, as the compiler and flags that were used to build your ROOT libraries (e.g. “root-config --libs”) and/or another C++ libraries that you want to use. Note: the real problems come from C++ code, not from C code (i.e. you can usually mix object code files and libraries that originate in C source code even if they were produced by different C compilers).

I’m also interested in building a standalone program that uses ROOT libraries on Windows. Is there any progress in this direction?

Hi,

[quote=“KBAKEP”]I’m also interested in building a standalone program that uses ROOT libraries on Windows. Is there any progress in this direction?[/quote]What do you mean? It has always been possible…
Just take a look at the example applications in $ROOTSYS/test

Cheers, Bertrand.

[quote=“bellenot”]Hi,
What do you mean? It has always been possible…
Just take a look at the example applications in $ROOTSYS/test

Cheers, Bertrand.[/quote]
Let me understand. Your answer means that it was always possible to build some exe file with ROOT functionality on one PC and use it on any other Windows computer without installing ROOT on that “other” PC. Is that right?

P.S. I have never programmed on Windows yet.

Oh sorry, I overlooked at the thread. In fact the easiest way is to install root on the other computer…

Cheers, Bertrand.

It’s pity. OK, thanks!

Dear Rooters,

I would like to make a standalone app (which uses Root syntax) on window. However, when I tried to compile, I get the following errors:

D:\Dropbox\Espace de travail\01 - NeutronDose_Thiem\example>g++ root-config --cflags --glibs ex.cc

g++: error: root-config: No such file or directory g++: error: unrecognized command line option '--cflags' g++: error: unrecognized command line option '--glibs

I used root 5.34 on windows 7.

ex.cc (996 Bytes)

I do not really Windows but I think it should be

g++ `root-config --cflags --glibs` ex.cc