Request: Better Instructions on non-ACLiC Compilation

Hi, often I wish to debug my code using valgrind or XCode Instruments, or gdb, or lldb, but the recommended method of running a program with “root -b myprogram.C+” does not permit such debugging.

I’ve sometimes been able to compile a separate binary (with a main function and all) and debug that way, but it is never obvious how to convert between a run-with-ROOT macro and a more independent binary that is just linked with ROOT, or how to maintain a piece of code that will work with both simultaneously (for example, I remember reading that you shouldn’t define a main function for run-with-ROOT code).

Also I did find this page: and I looked at the linked Makefile, but that’s rather unhelpful for a user needing just a few clang/gcc commands to compile their macro.

Here’s an example of what I’m looking for:
For the twoscales.C tutorial example, you could create a main.C file with the following contents:

#include "twoscales.C"
#include <iostream>
int main()
  // twoscales doesn't return anything, modify it to save the canvas to a file or something.
  std::cout << "Press any key." << std::endl;
  return 0;

Then the user would do these commands (clang++ has the same syntax as g++ here):

clang++ -c twoscales.C -I`root-config --incdir`
clang++ -shared -o twoscales.o -I`root-config --incdir` `root-config --glibs`
clang++ -o main.out main.C -I`root-config --incdir` `root-config --glibs` -L. -ltwoscales

This is all that is needed to compile a ROOT example outside of ACLiC. If the user’s case is very complex, they can perhaps learn about Makefiles themselves, but for simple cases such instructions would be a “stepping stone” or “breadcrumb” for the novice user to make the connection between “root mymacro.C+” and an independent binary executable.