Fail to build root from source with errors

Build from source but meet a lot of errors

[ 60%] Building CXX object roofit/histfactory/CMakeFiles/HistFactory.dir/src/ConfigParser.cxx.o
In file included from /Users/fermi/dev/root/root-6.26.02/roofit/histfactory/src/ConfigParser.cxx:19:
In file included from /Users/fermi/dev/root/root-6.26.02/roofit/histfactory/inc/RooStats/HistFactory/ConfigParser.h:16:
In file included from /Users/fermi/dev/root/root-6.26.02/roofit/histfactory/inc/RooStats/HistFactory/Measurement.h:21:
In file included from /Users/fermi/dev/root/root-6.26.02/io/io/inc/TFile.h:28:
In file included from /Users/fermi/dev/root/root-6.26.02/io/io/inc/TDirectoryFile.h:25:
In file included from /Users/fermi/dev/root/root-6.26.02/core/base/inc/TDirectory.h:25:
/Users/fermi/dev/root/root-6.26.02/core/meta/inc/TClass.h:272:12: error: 
      unknown type name 'Longptr_t'
   mutable Longptr_t  fOffsetStreamer;  //!saved info to call Streamer
           ^
/Users/fermi/dev/root/root-6.26.02/core/meta/inc/TClass.h:289:38: error: 
      unknown type name 'Longptr_t'
   TMethod           *GetClassMethod(Longptr_t faddr);
                                     ^
/Users/fermi/dev/root/root-6.26.02/core/meta/inc/TClass.h:387:63: error: 
      unknown type name 'Longptr_t'
   void               BuildEmulatedRealData(const char *name, Longptr_t ...
                                                              ^
/Users/fermi/dev/root/root-6.26.02/core/meta/inc/TClass.h:424:4: error: unknown
      type name 'Longptr_t'
   Longptr_t          GetDataMemberOffset(const char *membername) const;
   ^
/Users/fermi/dev/root/root-6.26.02/core/meta/inc/TClass.h:391:59: error: cannot
      initialize object parameter of type 'const TObject' with an expression of
      type 'TClass'
   Bool_t             CanIgnoreTObjectStreamer() { return TestBit(kIgnor...
                                                          ^~~~~~~
/Users/fermi/dev/root/root-6.26.02/core/meta/inc/TClass.h:396:51: error: cannot
      initialize object parameter of type 'const TObject' with an expression of
      type 'const TClass'
   void               Dump() const { TDictionary::Dump(); }
                                                  ^~~~
/Users/fermi/dev/root/root-6.26.02/core/meta/inc/TClass.h:431:33: error: cannot
      initialize object parameter of type 'const TObject' with an expression of
      type 'const TClass'
      if (fCanLoadClassInfo && !TestBit(kLoading))
                                ^~~~~~~
In file included from /Users/fermi/dev/root/root-6.26.02/roofit/histfactory/src/ConfigParser.cxx:19:
In file included from /Users/fermi/dev/root/root-6.26.02/roofit/histfactory/inc/RooStats/HistFactory/ConfigParser.h:16:
In file included from /Users/fermi/dev/root/root-6.26.02/roofit/histfactory/inc/RooStats/HistFactory/Measurement.h:25:
In file included from /Users/fermi/dev/root/root-6.26.02/roofit/histfactory/inc/RooStats/HistFactory/Asimov.h:17:
In file included from /Users/fermi/dev/root/root-6.26.02/roofit/roofitcore/inc/RooWorkspace.h:20:
In file included from /Users/fermi/dev/root/root-6.26.02/roofit/roofitcore/inc/RooArgSet.h:19:
In file included from /Users/fermi/dev/root/root-6.26.02/roofit/roofitcore/inc/RooAbsCollection.h:21:
In file included from /Users/fermi/dev/root/root-6.26.02/roofit/roofitcore/inc/RooAbsArg.h:39:
/Users/fermi/dev/root/root-6.26.02/core/cont/inc/THashList.h:70:15: warning: 
      'THashList::UseRWLock' hides overloaded virtual function
      [-Woverloaded-virtual]
   bool       UseRWLock(Bool_t enable = true);
              ^
/Users/fermi/dev/root/install/include/TCollection.h:206:23: note: hidden
      overloaded virtual function 'TCollection::UseRWLock' declared here:
      different number of parameters (0 vs 1)
   virtual bool       UseRWLock();
                      ^
1 warning and 7 errors generated.
make[2]: *** [roofit/histfactory/CMakeFiles/HistFactory.dir/src/ConfigParser.cxx.o] Error 1
make[1]: *** [roofit/histfactory/CMakeFiles/HistFactory.dir/all] Error 2
make: *** [all] Error 2

Here is the cmake options

-- ROOT Configuration 

System          Darwin-19.6.0
Processor       2 core Intel(R) Core(TM) i5-6267U CPU @ 2.90GHz (x86_64)
Build type      Release
Install path    /Users/fermi/dev/root/install
Compiler        AppleClang 12.0.0.12000032
Compiler flags:
C                -m64 -pipe -W -Wall -fsigned-char -fno-common -Qunused-arguments -pthread -O3 -DNDEBUG
C++              -std=c++14 -Wc++11-narrowing -Wsign-compare -Wsometimes-uninitialized -Wconditional-uninitialized -Wheader-guard -Warray-bounds -Wcomment -Wtautological-compare -Wstrncat-size -Wloop-analysis -Wbool-conversion -m64 -pipe -W -Wall -Woverloaded-virtual -fsigned-char -fno-common -Qunused-arguments -pthread -stdlib=libc++ -O3 -DNDEBUG
Linker flags:
Executable       -mmacosx-version-min=10.15
Module          
Shared          

-- Enabled support for:  asimage builtin_afterimage builtin_clang builtin_cling builtin_freetype builtin_ftgl builtin_glew builtin_llvm builtin_nlohmannjson builtin_openssl builtin_openui5 builtin_xxhash clad cocoa dataframe davix exceptions fftw3 fitsio gdml http imt libcxx mathmore mlp minuit2 opengl pyroot roofit rpath runtime_cxxmodules shared sqlite ssl tmva tmva-cpu tmva-pymva spectrum vdt xml

Please read tips for efficient and successful posting and posting code

ROOT Version: 6.26.02
Platform: macOS 10.15.7
Compiler: AppleClang 12.0.0.12000032


Did you start from a fresh build directory or reusing an existing one? Is there any other ROOT installation on the system?

Yes, I have a 6.18 version root on my laptop. I will remove it and try to build the new one again.

Solved after remove the old version of root.