How to easily use "easylogging++.h" in a root script, xxx.C

Hi all!
I am trying to add a log in my root script-“xxx.C”. I included “easylogging++.h” and initialize it with “INITIALIZE_EASYLOGGINGPP”。
I must compile xxx.C with easylogging++.h, right? if there is a easy way like “root -l xxx.C ??? easylogging++.h”
Thank you very much!


Please read tips for efficient and successful posting and posting code

ROOT Version: Not Provided
Platform: Not Provided
Compiler: Not Provided


Hi @11111 ,

if easylogging++.h is in the same directory as xxx.C, then root -l xxx.C+ should just work even if xxx.C includes easylogging++.h.

Otherwise I would suggest to switch to an actual standard, compiled C++ program (you might need to add some #includes and a main function to xxx.C) so you can pass the correct compilation options, e.g.:

$ g++ -o xxx xxx.C -I/path/to/easylogging/include $(root-config --libs --cflags)`

I hope this helps!
Enrico

H @eguiraud ,
Yes, the first way is OK. I missed something previously. Thank you very much!
BTW, I was wondering that when we “root -l”, what compiler we are using behind, still gcc?
Thank you!

Best,
Xin

root-config --cc
root-config --cxx

root macro.C uses ROOT’s C++ interpreter, cling, which is based on clang.

root macro.C+ compiles the macro code using the same compiler ROOT was built with (the one returned by root-config --cxx), then loads and runs the compiled code with cling.

Cheers,
Enrico

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.