Problem with make command when trying to write and read files with ROOT and C++

I am working through the CMS Open Data Workshop information from 2021 and I have gotten stuck on the “Using ROOT with C++ to write and read a file” in the “C++ and ROOT basics” section. I have created the write_ROOT_file, read_ROOT_file, and Makefile all as described in the lesson. Every time I try to run the “make write_ROOT_file” command, I get an error message. The error message I get says:

g++ -o write_ROOT_file.o write_ROOT_file.cc
write_ROOT_file.cc:5:19: fatal error: TROOT.h: No such file or directory
compilation terminated.
make: *** [write_ROOT_file] Error 1

I have run the “cmsenv” command several times, I have access to ROOT in the shell, and I have rearranged the order of the “#include” commands at the beginning of the file to see if any of these were causing the problem. None of these helped or changed the error message in any way. Can anyone help me to fix my make command so that I will be able to run my files?

Hi! Thanks for your interest. We are a bit busy with the CMS open data workshop that is going to take place next week. Would you maybe have a look to the corresponding instructions for this year’s workshop in ROOT with C++ and python
Note that we recommend using the docker containers that have been prepared for the purpose, with the necessary libraries installed. If you are interested using them, please check Docker pre-exercises

Hope this helps!

Best, Kati
for the CMS Open data team