Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[CMake] Existing ROOT headers from the system might be picked up when compiling ROOT #13101

Open
1 task done
ynikitenko opened this issue Jun 26, 2023 · 9 comments · May be fixed by #8709
Open
1 task done

[CMake] Existing ROOT headers from the system might be picked up when compiling ROOT #13101

ynikitenko opened this issue Jun 26, 2023 · 9 comments · May be fixed by #8709

Comments

@ynikitenko
Copy link

ynikitenko commented Jun 26, 2023

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.

@ynikitenko ynikitenko added the bug label Jun 26, 2023
@guitargeek guitargeek self-assigned this Jun 26, 2023
@guitargeek guitargeek assigned bellenot and unassigned guitargeek Jun 26, 2023
@guitargeek guitargeek changed the title Can't install RooFit because of JSONFactories and JSONNode [CMake] Existing ROOT headers from the system might be picked up when compiling ROOT Jun 26, 2023
@guitargeek
Copy link
Contributor

Hi! It seems ROOT picks up some outdated headers from /opt/root/install/include/ during the build.

This is a general problem that has nothing to do with RooFit, I have seen it several times happening in different contexts before.

You can avoid this problem by un-installing ROOT from your system before you build the new ROOT version.

Since this is a build-related issue, I have changed the issue title to reflect this and have assigned @bellenot.

If uninstalling the existing ROOT release is not an acceptable solution for you for whatever reason, maybe @bellenot can comment more on what are the options.

@ynikitenko
Copy link
Author

@guitargeek thank you! I'm glad that ROOT doesn't have so many errors :) Yes, this is a strange issue.

@bellenot
Copy link
Member

bellenot commented Jun 27, 2023

Sorry, I have no experience with Linux install/uninstall/update procedures, but I'll try to figure out what can be done (not sure if it's really a CMake/ROOT issue though)

@ynikitenko
Copy link
Author

So I deleted my freshly installed ROOT and pulled the newest version from the repository. When running

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

I got an error

`-- Looking for VDT
CMake Error at cmake/modules/FindVdt.cmake:48 (file):
file STRINGS file "/opt/root/install/include/vdt/vdtMath.h" cannot be read.
Call Stack (most recent call first):
cmake/modules/SearchInstalledSoftware.cmake:18 (_find_package)
cmake/modules/SearchInstalledSoftware.cmake:1591 (find_package)
CMakeLists.txt:327 (include)

-- Could NOT find Vdt: Found unsuitable version "0.3", but required is at least "0.4" (found /opt/root/install/include)
-- VDT not found. Ensure that the installation of VDT is in the CMAKE_PREFIX_PATH
-- Switching ON 'builtin_vdt' option
`

As I wrote, the directory /opt/root/install does not exist. When running the same command for the second time, the error is gone.

@eguiraud
Copy link
Contributor

eguiraud commented Jul 3, 2023

CMake thinks /opt/root/install exists. Maybe it's picking up and old cmake configuration from the build directory?

If the directory does not exist, starting fresh from an empty build directory with no ROOT binary available in your environment should work fine.

(the command works the second time because after the first time ROOT switches the cmake configuration to builtin_vdt, so it does not look for VDT in the system anymore).

@guitargeek
Copy link
Contributor

guitargeek commented Nov 7, 2023

I have no solution here, just making the cross reference that this is almost a duplicate of this issue:

So these two issues can probably be fixed in one go.

@dpiparo
Copy link
Member

dpiparo commented Feb 5, 2024

Is this perhaps what this PR #8709 tries to solve?

@guitargeek
Copy link
Contributor

I think so, yes. We should bump the priority of this, because the problem with compiling ROOT when there is already ROOT on the system comes back often (I just closed a duplicate issue once again).

@hageboeck
Copy link
Member

Is this perhaps what this PR #8709 tries to solve?

Yes, this is what the PR tries to solve. I'm reviving this PR now.

@ynikitenko, I would like to find the package that caused this behaviour for you. It looks like it's either VDT (which should hopefully be fixed by this PR) or nlohmann::json.

Is there a way you can get the log of the first CMake configure run? I would like to know if CMake managed to find json or VDT in the system directories. If you don't have it, no worries, I'll just double check that it's not json, and we hope that the fix for VDT works.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
6 participants