Can't compile cpp script with ROOT libraries; libraries not found?

Hello everyone,

I am trying to compile a piece of code containing ROOT libraries, call it “my_script.cpp”, using gcc. I’m running Max OS 12.7.5 and ROOT version 6.30/04. This is an old script that used to work for me (about three years ago), but I recently found new use for it and only now something has broken. The error I get is:

my_script.cpp: fatal error: ‘TROOT.h’ file not found

I have tried explicitly including the full directory path to TROOT.h to resolve this, but then I get the following:

/Users/my_user/opt/anaconda3/envs/CernROOT/include/ROOT/RConfig.hxx:23:10: fatal error: ‘RConfigure.h’ file not found

Note that I have installed ROOT using Conda, and I have appropriately activated my conda environment containing ROOT. Prior to this, I had installed ROOT via Homebrew, and got virtually identical errors.

I have also tried re-installing the Xcode command line tools, just in case that would help, but no luck. (Didn’t expect it to.)

What can I do to resolve this? Thanks in advance.

_ROOT Version: 6.30/04
_Platform: Mac OS 12.7.5
_Compiler: gcc

Hello @eggsAndCoffee,

can you please share the command you’re using for compiling?

Cheers,
Monica

Of course! It’s the following:

gcc my_script.cpp -o my_script

You’re not linking against the ROOT library. Try
gcc my_script.cpp -o my_script `root-config --cflags --libs`

Ah okay, thanks!

I’ve gotten a new error now.

1 warning generated.
Undefined symbols for architecture x86_64:
  "___gxx_personality_v0", referenced from:
      _main in hello_world-7fd1c7.o
      Dwarf Exception Unwind Info (__eh_frame) in hello_world-7fd1c7.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

That error was generated by trying to compile a simple hello_world.cpp program (attached here)
hello_world.cpp (353 Bytes) using the following command:

gcc hello_world.cpp -o hello_world `root-config --cflags --libs`

I’m not sure what the “__gxx_personality_v0” symbol it’s referring to is. Have I missed another link to ROOT?

Ah! Caught it. Using g++ instead of gcc is the way to go.

@mdessole thanks very much for your help.

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