Strange errors when including <array>

Hi,
I am trying to compile some code from the root command line where I use std:array. However, already including the header produces lots of error messages. This is how my code looks like:

#include <array>
#include <iostream>
void main(){
    std::cout << "HALLO WELT" << std::endl;
}

With CL.exe it compiles without problems, but when i try

I get the following errors (xyz is my working directory):

299252_cint.cxx D:\xyz\AutoDict_vector_vector_string_allocator_string_____.cxx(2) : fatal error C1083: Cannot open include file: 'C:\vector': No such file or dir ectory Error: external preprocessing failed. (0) !!!Removing D:\xyz\AutoDict_vector_vector_string_allocator_string ______cxx_ACLiC_dict.cxx D:\xyz\AutoDict_vector_vector_string_all ocator_string______cxx_ACLiC_dict.h !!! Error: C:\root_v5.34.21\bin\rootcint: error loading headers... Error in <ACLiC>: Dictionary generation failed! 2203252_cint.cxx D:\xyz\AutoDict_random_access_iterator_vector_string_allocator_st ring____long_.cxx(2) : fatal error C1083: Cannot open include file: 'C:\vector': No such file or directory Error: external preprocessing failed. (0) !!!Removing D:\xyz\AutoDict_random_access_iterator_vector_string_ allocator_string____long__cxx_ACLiC_dict.cxx D:\xyxz\AutoDict_rand om_access_iterator_vector_string_allocator_string____long__cxx_ACLiC_dict.h !!! Error: C:\root_v5.34.21\bin\rootcint: error loading headers... Error in <ACLiC>: Dictionary generation failed!

and when I try

I get

Info in <ACLiC>: script has already been loaded in interpreted mode
Info in <ACLiC>: unloading D:\xyz\TestArrayInclude.cpp and compil
ing it
Error: Symbol G__ARRAYMAX is not defined in current scope  graphbuf.h(139)
Error: Binary operator oprand missing graphbuf.h(139)
Info in <TWinNTSystem::ACLiC>: creating shared library D:\xyz\TestArrayInclude_cpp.dll
2431252_cint.cxx
Error: Symbol _Size is not defined in current scope  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(21)
Error: no such template array<_Ty,_Size> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(22)
Error: class,struct,union or type _Ty not defined  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(23)
Error: class,struct,union or type _Ty not defined  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(26)
Error: class,struct,union or type _Ty not defined  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(27)
Error: class,struct,union or type _Ty not defined  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(28)
Error: class,struct,union or type _Ty not defined  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(29)
Error: no such template _Array_iterator<_Ty,_Size> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(31)
Error: no such template _Array_const_iterator<_Ty,_Size> C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(32)
Error: class,struct,union or type _STD not defined  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(34)
Error: class,struct,union or type _STD not defined  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(35)
Error: Symbol _Size is not defined in current scope  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(210)
Error: Symbol _Size is not defined in current scope  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(210)
Error: Symbol _Ty _Elems[_Size==0?1:_Size] is not defined in current scope  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(210)
Error: Symbol array is not defined in current scope  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(537)
Error: Symbol get is not defined in current scope  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(538)
Error: Symbol tuple_element is not defined in current scope  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(539)
Error: Symbol tuple_size is not defined in current scope  C:\Program Files (x86)\Microsoft Visual Studio 11.0\VC\INCLUDE\array(540)
Warning: Error occurred during reading source files
Warning: Error occurred during dictionary source generation
!!!Removing D:\xyz\TestArrayInclude_cpp_ACLiC_dict.cxx D:\xyz\TestArrayInclude_cpp_ACLiC_dict.h !!!
Error: C:\root_v5.34.21\bin\rootcint: error loading headers...
Error in <ACLiC>: Dictionary generation failed!
Info in <ACLiC>: Invoking compiler to check macro's validity
!!!Dictionary position not recovered because G__unloadfile() is used in a macro!
!!
*** Interpreter error recovered ***

What is wrong with including ?

I always thought that “.L …++” is simply calling the compiler (CL.exe in this case) with appropriate options and that it is more or less equivalent to building the lib “by hand” via using the compiler (CL.exe) outside of root. What is the difference?

PS: I can include e.g. and use them without problems. Thats why I think the problem is not related to environment variables / include paths.

Hi HobbyBastler,

you are hitting a limitation of Cint: Cint is not able to deal with c++11 headers, for example arrays.

This is almost correct. The difference is the automatic creation of a dictionary.
The solution to this issue is represented by ROOT6, where your example runs flawlessly. Unfortunately root6 is not yet supported on windows: we are working hard on that.

Best,
Danilo

Good to know that it will come soon. In the meanwhile I would like to use the CL.exe alone and link to the root libs by hand. However, I dont have big experience with building C++ projects and when I call it via

CL myCode.cpp /link C:\root[...]\lib\libHist.lib

where myCode.cpp has a

#include "TH1.h"

the linker spits out the following error:

myCode.obj : error LNK2019: unresolved external symbol "public: __this
call TVersionCheck::TVersionCheck(int)" (??0TVersionCheck@@QAE@H@Z) referenced i
n function "void __cdecl `dynamic initializer for 'gVersionCheck''(void)" (??__E
gVersionCheck@@YAXXZ)
myCode.exe : fatal error LNK1120: 1 unresolved externals

I know that this is not really a problem with cint (maybe not even root related) but it would be nice if someone could help me with it.

Hi,

Try:

cl -nologo -DWIN32 -W3 -D_WINDOWS -MD -GR -EHsc myCode.cpp -I %ROOTSYS%\include /link -LIBPATH:%ROOTSYS%\lib libCore.lib libHist.lib And note that you may have to link against more libraries, depending on what you do in your code…

Cheers, Bertrand.