Repository: root-project/root

Issue #13101: [CMake] Existing ROOT headers from the system might be picked up when compiling ROOT
Created: 2023-06-26T19:20:23Z
Check duplicate issues.

 Checked for duplicates

Description
Can't install RooFit because of RooJSON.
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx: In member function ‘virtual bool {anonymous}::RooExpPolyStreamer::exportObject(RooJSONFactoryWSTool*, const RooAbsArg*, RooFit::Detail::JSONNode&) const’:
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx:448:25: error: ‘const class RooExpPoly’ has no member named ‘x’; did you mean ‘RooRealProxy RooExpPoly::_x’? (not accessible from this context)
  448 |       elem["x"] << pdf->x().GetName();
      |                         ^
In file included from /opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx:20:
/opt/root/install/include/RooExpPoly.h:37:17: note: declared protected here
   37 |    RooRealProxy _x;
      |                 ^~
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx:453:32: error: ‘const class RooExpPoly’ has no member named ‘lowestOrder’; did you mean ‘int RooExpPoly::_lowestOrder’? (not accessible from this context)
  453 |       for (int i = 0; i < pdf->lowestOrder(); ++i) {
      |                                ^~~~~~~~~~~
/opt/root/install/include/RooExpPoly.h:39:8: note: declared protected here
   39 |    int _lowestOrder;
      |        ^~~~~~~~~~~~
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx:456:36: error: ‘const class RooExpPoly’ has no member named ‘coefList’; did you mean ‘RooListProxy RooExpPoly::_coefList’? (not accessible from this context)
  456 |       for (const auto &coef : pdf->coefList()) {
      |                                    ^~~~~~~~
/opt/root/install/include/RooExpPoly.h:38:17: note: declared protected here
   38 |    RooListProxy _coefList;
      |                 ^~~~~~~~~
make[2]: *** [roofit/hs3/CMakeFiles/RooFitHS3.dir/build.make:132: roofit/hs3/CMakeFiles/RooFitHS3.dir/src/JSONFactories_RooFitCore.cxx.o] Error 1

Tried to change method names to those with underscores, got another error about a protected field:
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx: In member function ‘virtual bool {anonymous}::RooExpPolyStreamer::exportObject(RooJSONFactoryWSTool*, const RooAbsArg*, RooFit::Detail::JSONNode&) const’:
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx:448:25: error: ‘RooRealProxy RooExpPoly::_x’ is protected within this context
  448 |       elem["x"] << pdf->_x().GetName();
      |                         ^~
In file included from /opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx:20:
/opt/root/install/include/RooExpPoly.h:37:17: note: declared protected here
   37 |    RooRealProxy _x;
      |                 ^~
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx:448:27: error: no match for call to ‘(const RooRealProxy {aka const RooTemplateProxy<RooAbsReal>}) ()’
  448 |       elem["x"] << pdf->_x().GetName();
      |                    ~~~~~~~^~
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx:453:32: error: ‘int RooExpPoly::_lowestOrder’ is protected within this context
  453 |       for (int i = 0; i < pdf->_lowestOrder(); ++i) {
      |                                ^~~~~~~~~~~~
/opt/root/install/include/RooExpPoly.h:39:8: note: declared protected here
   39 |    int _lowestOrder;
      |        ^~~~~~~~~~~~
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx:453:44: error: expression cannot be used as a function
  453 |       for (int i = 0; i < pdf->_lowestOrder(); ++i) {
      |                           ~~~~~~~~~~~~~~~~~^~
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx:456:36: error: ‘RooListProxy RooExpPoly::_coefList’ is protected within this context
  456 |       for (const auto &coef : pdf->_coefList()) {
      |                                    ^~~~~~~~~
/opt/root/install/include/RooExpPoly.h:38:17: note: declared protected here
   38 |    RooListProxy _coefList;
      |                 ^~~~~~~~~
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx:456:45: error: no match for call to ‘(const RooListProxy {aka const RooCollectionProxy<RooArgList>}) ()’
  456 |       for (const auto &coef : pdf->_coefList()) {
      |                               ~~~~~~~~~~~~~~^~
make[2]: *** [roofit/hs3/CMakeFiles/RooFitHS3.dir/build.make:132: roofit/hs3/CMakeFiles/RooFitHS3.dir/src/JSONFactories_RooFitCore.cxx.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:44184: roofit/hs3/CMakeFiles/RooFitHS3.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Commented the body of the whole function. Got another error.
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx: In member function ‘virtual bool {anonymous}::RooExpPolyStreamer::exportObject(RooJSONFactoryWSTool*, const RooAbsArg*, RooFit::Detail::JSONNode&) const’:
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx:444:63: warning: unused parameter ‘func’ [-Wunused-parameter]
  444 |    bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
      |                                              ~~~~~~~~~~~~~~~~~^~~~
/opt/root/src/roofit/hs3/src/JSONFactories_RooFitCore.cxx:444:79: warning: unused parameter ‘elem’ [-Wunused-parameter]
  444 |    bool exportObject(RooJSONFactoryWSTool *, const RooAbsArg *func, JSONNode &elem) const override
      |                                                                     ~~~~~~~~~~^~~~
[ 98%] Linking CXX shared library ../../lib/libRooFitHS3.so
/usr/bin/ld: CMakeFiles/RooFitHS3.dir/src/JSONFactories_HistFactory.cxx.o: in function `std::vector<double, std::allocator<double> >& RooFit::Detail::operator<< <double>(std::vector<double, std::allocator<double> >&, RooFit::Detail::JSONNode const&) [clone .isra.0]':
JSONFactories_HistFactory.cxx:(.text+0xc212): undefined reference to `double RooFit::Detail::JSONNode::val_t<double>() const'
collect2: error: ld returned 1 exit status
make[2]: *** [roofit/hs3/CMakeFiles/RooFitHS3.dir/build.make:200: lib/libRooFitHS3.so] Error 1
make[1]: *** [CMakeFiles/Makefile2:44184: roofit/hs3/CMakeFiles/RooFitHS3.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....

Reproducer
Clone ROOT repository, go to the build directory,

cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=../install ../src
cmake --build . -- install -j4

ROOT version
Most recent ROOT version from the master branch at that time.

commit 870618f (HEAD -> master, origin/master, origin/HEAD)

Should I use that? I thought there is continuous integration and people check for errors before committing.
Installation method
built from source
Operating system
Arch Linux
Additional context
Had to remove RooFit support from CMakeCache.txt.

Duplicate issue #13102: Can't compile RModelParser_Keras
Created: 2023-06-26T19:25:36Z
Check duplicate issues.

 Checked for duplicates

Description
When compiling ROOT from source, I got an error:
/opt/root/src/tmva/pymva/src/RModelParser_Keras.cxx: In function ‘std::unique_ptr<TMVA::Experimental::SOFIE::ROperator> TMVA::Experimental::SOFIE::PyKeras::INTERNAL::MakeKerasSwish(PyObject*)’:
/opt/root/src/tmva/pymva/src/RModelParser_Keras.cxx:562:23: error: ‘ROperator_Swish’ does not name a type; did you mean ‘ROperator_Slice’?
  562 |          op.reset(new ROperator_Swish<float>(fLayerInputName, fLayerOutputName));
      |                       ^~~~~~~~~~~~~~~
      |                       ROperator_Slice
/opt/root/src/tmva/pymva/src/RModelParser_Keras.cxx:562:39: error: expected primary-expression before ‘float’
  562 |          op.reset(new ROperator_Swish<float>(fLayerInputName, fLayerOutputName));
      |                                       ^~~~~
make[2]: *** [tmva/pymva/CMakeFiles/PyMVA.dir/build.make:146: tmva/pymva/CMakeFiles/PyMVA.dir/src/RModelParser_Keras.cxx.o] Error 1
make[2]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:42937: tmva/pymva/CMakeFiles/PyMVA.dir/all] Error 2
make[1]: *** Waiting for unfinished jobs....
make[1]: *** [CMakeFiles/Makefile2:44293: roofit/xroofit/CMakeFiles/RooFitXRooFit.dir/all] Error 2
make: *** [Makefile:156: all] Error 2

Had to add a line
+++ b/tmva/pymva/src/RModelParser_Keras.cxx
@@ -18,6 +18,7 @@
**********************************************************************************/
#include "TMVA/RModelParser_Keras.h"
+#include "TMVA/ROperator_Swish.hxx"
I'm not sure the include had to be added in that file, but it worked.
Reproducer
Clone ROOT repository, go to the build directory,
cmake -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_INSTALL_PREFIX=../install ../src
cmake --build . -- install -j4

ROOT version
Most recent ROOT version from the master branch at that time.
commit https://github.com/root-project/root/commit/870618f1bfa43376c73bc07fa4becc0a54caa9ed (HEAD -> master, origin/master, origin/HEAD)

Installation method
built from source
Operating system
Arch Linux
Additional context
No response

Closing comment (2023-06-26T22:38:10Z): Duplicate of #13101.