Standalone application compilation error with TString.h

I’m running root 6.10.02 on a mac (Sierra 12.6), and have run into an issue with TString.h and getting an series of errors related to unknown type name issues. To test demonstrate it, I’ve written a simple hello code,

#include <iostream>

//#include <TString.h>

int main()
{
  std::cout << "Hello World" << std::endl;
  return 0;
}

which compiles fine, but when I remove the comment from the #include <TString.h> I get the following:

>g++ `root-config --cflags --glibs`  -o hello test.cc
In file included from test.cc:3:
In file included from /usr/local/root/install/include/TString.h:28:
/usr/local/root/install/include/RStringView.h:35:12: error: unknown type name 'basic_string_view'
   typedef basic_string_view<char> string_view;
           ^
/usr/local/root/install/include/RStringView.h:35:29: error: expected unqualified-id
   typedef basic_string_view<char> string_view;
                            ^
/usr/local/root/install/include/RStringView.h:36:12: error: unknown type name 'basic_string_view'
   typedef basic_string_view<char16_t> u16string_view;
           ^
/usr/local/root/install/include/RStringView.h:36:29: error: expected unqualified-id
   typedef basic_string_view<char16_t> u16string_view;
                            ^
/usr/local/root/install/include/RStringView.h:37:12: error: unknown type name 'basic_string_view'
   typedef basic_string_view<char32_t> u32string_view;
           ^
/usr/local/root/install/include/RStringView.h:37:29: error: expected unqualified-id
   typedef basic_string_view<char32_t> u32string_view;
                            ^
/usr/local/root/install/include/RStringView.h:38:12: error: unknown type name 'basic_string_view'
   typedef basic_string_view<wchar_t> wstring_view;
           ^
/usr/local/root/install/include/RStringView.h:38:29: error: expected unqualified-id
   typedef basic_string_view<wchar_t> wstring_view;
                            ^
8 errors generated.

Hi,

I have also encountered this problem but did not manage to solve it. I would be very interested in a solution.

I think it is related to installing llvm through a third-party solution (homebrew, macports or what have you) and the compiler getting confused about where to look for headers (picking up the system headers).

However, I’ve not had time to properly look into in :confused:

Cheers,
Kim

Hi,
can you post the contents of your $ROOTSYS/include/RConfigure.h?

Relevant part

...snip...
#define R__USE_LIBCXX    /**/
#undef R__HAS_STD_STRING_VIEW   /**/
#define R__HAS_STD_EXPERIMENTAL_STRING_VIEW   /**/
#undef R__HAS_STOD_STRING_VIEW /**/
...snip...

And here is my version:

#ifndef ROOT_RConfigure
#define ROOT_RConfigure

/* Configurations file for macosx64 */
#ifdef R__HAVE_CONFIG
#define ROOTPREFIX    "$(ROOTSYS)"
#define ROOTBINDIR    "$(ROOTSYS)/bin"
#define ROOTLIBDIR    "$(ROOTSYS)/lib"
#define ROOTINCDIR    "$(ROOTSYS)/include"
#define ROOTETCDIR    "$(ROOTSYS)/etc"
#define ROOTDATADIR   "$(ROOTSYS)/."
#define ROOTDOCDIR    "$(ROOTSYS)/."
#define ROOTMACRODIR  "$(ROOTSYS)/macros"
#define ROOTTUTDIR    "$(ROOTSYS)/tutorials"
#define ROOTSRCDIR    "$(ROOTSYS)/src"
#define ROOTICONPATH  "$(ROOTSYS)/icons"
#define TTFFONTDIR    "$(ROOTSYS)/fonts"
#endif

#define EXTRAICONPATH ""

#undef R__HAS_SETRESUID   /**/
#undef R__HAS_MATHMORE   /**/
#define R__HAS_PTHREAD    /**/
#undef R__HAS_XFT    /**/
#define R__HAS_COCOA    /**/
#undef R__HAS_VC    /**/
#define R__USE_CXX11    /**/
#undef R__USE_CXX14    /**/
#undef R__USE_CXX17    /**/
#define R__USE_LIBCXX    /**/
#undef R__HAS_STD_STRING_VIEW   /**/
#define R__HAS_STD_EXPERIMENTAL_STRING_VIEW   /**/
#undef R__HAS_STOD_STRING_VIEW /**/
#undef R__HAS_STD_APPLY /**/
#undef R__HAS_STD_INVOKE /**/
#undef R__EXTERN_LLVMDIR /**/
#define R__USE_IMT   /**/

#endif

I can add a couple more points:

  • I see the same problem when I try to compile interactively via .L *+

  • I have an older Mac, with the same OS and version of root, that does not have this problem. The problem is on my new Mac, with an essentially fresh install of the OS.

Problem is definitely in how I have things configured.

Looks like ROOT is not behaving correctly when R__HAS_STD_EXPERIMENTAL_STRING_VIEW is defined, which is true for both of you.

You can try to compile the following without ROOT flags, which is what ROOT does internally to make std::string_view available, and hopefully it will give you the same errors:

EDIT: code was not proper c++ :sweat_smile:

#include <experimental/string_view>
template<class _CharT, class _Traits = std::char_traits<_CharT> >                                                    
using basic_string_view = ::std::experimental::basic_string_view<_CharT,_Traits>;

int main() {                                                                     
   typedef basic_string_view<char> string_view;  
   return 0;
}

I get the following, which does reproduce the problem:

>g++ -o test2  test2.cc
test2.cc:4:4: error: expected expression
   template<class _CharT, class _Traits = std::char_traits<_CharT> ...
   ^
test2.cc:7:12: error: no template named 'basic_string_view'; did you mean 'std::basic_string_view'?
   typedef basic_string_view<char> string_view;  
           ^~~~~~~~~~~~~~~~~
           std::basic_string_view
/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/include/c++/v1/string_view:185:28: note: 
      'std::basic_string_view' declared here
class _LIBCPP_TEMPLATE_VIS basic_string_view {
                           ^
2 errors generated.`

Yeah but my original snippet was wrong unfortunately.

I think @pcanal can help better than me at this point :slight_smile:

Okay, I reran the corrected snippet, and it compiles fine, with a warning about C++11 extensions

>g++ -o test2 test2.cc
test2.cc:3:27: warning: alias declarations are a C++11 extension [-Wc++11-extensions]
using basic_string_view = ::std::experimental::basic_string_view<_CharT,_Traits>;
                          ^
1 warning generated.

Hello, I saw the same error and it appears to be related to upgrading to clang 9.0.0 in XCode 9.0. After upgrading root does not build at all. I made the following JIRA ticket: https://sft.its.cern.ch/jira/browse/ROOT-9015

That makes sense to me, as the Mac on which I do not have the problem has Xcode 8.3.3.

We have not yet released any binary compatible with XCode 9.

XCode 9 introduced changes in the standard library that is incompatible with old version of ROOT. There is a slight chance, depending on which plugin you need and which exact version that ‘just’ reconfigure and recompiling from scratch.

If it doesn’t you will need to use the master with commit 263508429dec26449513914e71f0f71c9ce9485f or newer.

Cheers,
Philippe.

1 Like

Hello,

So I have tried to compile by hand ROOT from the sources. The problem is that at the linking stage he doesn’t want to link against the XMLParser library:

clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [lib/libXMLParser.so] Error 1
make: *** Waiting for unfinished jobs…

Is there any fix to this?

Thanks,
Marcin

I have had this issue as well. Instead of getting complicated with workarounds, I decided to downgrade my Xcode to version 8. Here is the Apple Developer website where you can get older versions of Xcode: https://developer.apple.com/download/more/
Everything works well now!

1 Like

I had this issue too – I found that ROOT was broken after macOS auto-updated to xcode 9, so I attempted to compile v6-10-06 and got the same basic_string_view error as above. the Taking Philippe’s suggestion, I compiled from the head of the master branch (commit 2c8c75ad5e6c7393aa2bd0086a5ecddb29f8686f) and it compiled fine. Things seem to be working now.

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