I have written some classes which I have turned into a shared library called TParticle.so .
Additionally, I have somewhat long, mostly C macro which I usually compile and execute in the following manner:
root  .L TParticle.so
root  .L doit.cpp+
root  doit(100, 100) , where my function takes two integers.
In any case, my macro has become much too long and I wish to break it up into several files, such as :
I would like to be able to compile these files together and execute my macro on the command line, but so far I have been unsuccessful. I’ve considered just compiling all of this together in a shared library, as I did for TParticle.so, but it seems wrong to me, as this is just a macro with several helper functions. I’ve also tried looking at sample makefiles to use gcc to link the root libraries, my TParticle library and these macro .h and .cpp files together , but all of the makefiles are very tedious and general, and I’m just hoping to get something simple which will allow me to go to the command line and type
root  .L myprogram.appropriateextension(+)
root  doit(100,100)
Thanks in advance for considering this post. I am mainly trying to learn the appropriate way to do this programming, such that I can build larger and more successful programs in the proper way.
I would recommend against using the word TParticle as it is also the name of an official ROOT class.
In the first approximation, you can simply #include helper1.cpp and helper2.cpp in doit.cpp and do
Also note that if you add
#pragma link C++ function myherlper_function;
in any of this file, this request will be honored by ACLiC.
You can also simply write a macro loader.C
and then do
I am facing the same problem, pcanal’s answer helped me solve at least the compiling part, but once I have compiled all the source (cpp) files using .L file.cpp+, how do I link those .so files ? Suppose I have a main macro, macro.cpp and two headers, h1.cpp, h1.h and h2.cpp and h2.h, macro.cpp calls functions from h1 and h2, after compiling them all I get macro_cpp.so, h1_cpp.so and h2_cpp.so… how to proceed ?
See also ACLiC complains about almost everything, why doesn't it recognize any ROOT Types like TCanvas etc?
Repeating the same question on four threads (if I counted correctly) doesn’t get you closer to an answer but makes it more confusing for you, us and anybody else with the same question who is trying to find your solution.
Finally solved it Is there any tutorial on running root entirely with g++?, the questions are different but related.