# 'gSystem-\>Load()' cause 'cout\<\<anything\<\<endl;' crash root comand line on Win10

**URL:** <https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134>\
**Category:** Newbie\
**Created:** [August 25, 2020, 1:21pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134 "2020-08-25T13:21:02Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![Zhenhao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zhenhao/32/23177_2.png) [@Zhenhao](https://root-forum.cern.ch/u/Zhenhao)\
**Post date:** [August 25, 2020, 1:21pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/1 "2020-08-25T13:21:02Z")

</div>

* * *

_ROOT Version:_ 6.16.0 and 6.22  
_Platform:_ win 10  
_Compiler:_ Cling

* * *

Hello,

I am troubled by a strange behavior. Root comand line will crash for “cout\<\<anything\<\<endl;” if I use  
‘gSystem-\>Load()’ to load a dll or lib file.

I also find that I can’t use ‘gSystem-\>Load()’ to load ‘.lib’ file in command line, but I can use it in rootlogon.C file successfully.

Any suggestions will be great!

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 25, 2020, 1:32pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/2 "2020-08-25T13:32:27Z")

</div>

> [@Zhenhao](#):
>
> I am troubled by a strange behavior. Root comand line will crash for “cout\<\<anything\<\<endl;” if I use  
> ‘gSystem-\>Load()’ to load a dll or lib file.

I can’t reproduce the issue you describe:

```auto
C:\Users\bellenot\rootdev>root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.23/01 https://root.cern |
  | (c) 1995-2020, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for win32 on Aug 24 2020, 08:34:25 |
  | From heads/master@v6-23-01-1046-g8665644005 |
  | With |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------------

root [0] gSystem->Load("libMathMore.dll")
(int) 0
root [1] std::cout << "hello" << std::endl;
hello
root [2]

```

> [@Zhenhao](#):
>
> I also find that I can’t use ‘gSystem-\>Load()’ to load ‘.lib’ file in command line, but I can use it in rootlogon.C file successfully.

IIRC, `gSystem->Load()` is meant to load DLLs. BTW, did you start ROOT in a `x86 Native Tools Command Prompt for VS 2019`?

---

<div class="post-metadata">

**Author:** ![Zhenhao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zhenhao/32/23177_2.png) [@Zhenhao](https://root-forum.cern.ch/u/Zhenhao)\
**Post date:** [August 25, 2020, 1:39pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/3 "2020-08-25T13:39:55Z")

</div>

I just find out that I can use `gSystem->Load(pathtoLibFile)` in command line if I start `ROOT in a x86 Native Tools Command Prompt for VS 2019`. But, still, if I use `std::cout << "hello" << std::endl;`, it will print “hello” then quit root. And `std::cout <<int, double .etc. << std::endl;` will crash command line.

---

<div class="post-metadata">

**Author:** ![Zhenhao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zhenhao/32/23177_2.png) [@Zhenhao](https://root-forum.cern.ch/u/Zhenhao)\
**Post date:** [August 25, 2020, 1:42pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/4 "2020-08-25T13:42:14Z")

</div>

Maybe I use the word ‘crash’ wrongly. By ‘crash’ I mean `std::cout << anynumber << std::endl;` will print an empty line and then quit root.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 25, 2020, 1:44pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/5 "2020-08-25T13:44:47Z")

</div>

> [@Zhenhao](#):
>
> I just find out that I can use `gSystem->Load(pathtoLibFile)` in command line if I start `ROOT in a x86 Native Tools Command Prompt for VS 2019` .

Yes, please start ROOT from there, so it can find the proper system header files.  
And for the `std::endl` issue, I still can’t reproduce the issue:

```auto
C:\Users\bellenot\rootdev>root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.23/01 https://root.cern |
  | (c) 1995-2020, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for win32 on Aug 24 2020, 08:34:25 |
  | From heads/master@v6-23-01-1046-g8665644005 |
  | With |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------------

root [0] std::cout << 0.04 << std::endl;
0.04
root [1] gSystem->Load("libMathMore.dll")
(int) 0
root [2] std::cout << 0.04876 << " " << 12345 << std::endl;
0.04876 12345
root [3]

```

But you can most probably use ` << '\n';` (or ` << "\n";`) instead

---

<div class="post-metadata">

**Author:** ![Zhenhao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zhenhao/32/23177_2.png) [@Zhenhao](https://root-forum.cern.ch/u/Zhenhao)\
**Post date:** [August 25, 2020, 1:45pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/6 "2020-08-25T13:45:21Z")

</div>

I’m sorry, but I find the version I use is 6.22/02, not 6.23. It’s a precompiled version. I thought I tried 6.23. I tried some versions and I make it wrong. I guess I didn’t try 6.23.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 25, 2020, 1:47pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/7 "2020-08-25T13:47:20Z")

</div>

OK, anyway, you can try to use `<< '\n';` (or `<< "\n";` ) instead of `<< std::endl;`

---

<div class="post-metadata">

**Author:** ![Zhenhao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zhenhao/32/23177_2.png) [@Zhenhao](https://root-forum.cern.ch/u/Zhenhao)\
**Post date:** [August 25, 2020, 1:49pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/8 "2020-08-25T13:49:45Z")

</div>

`'\n';` (or `<< "\n";` )` is the same as `std::endl;`.

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 25, 2020, 1:50pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/9 "2020-08-25T13:50:37Z")

</div>

OK, I’ll try to reproduce the error…

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 25, 2020, 2:04pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/10 "2020-08-25T14:04:59Z")

</div>

BTW, which version of Visual Studio are you using?

---

<div class="post-metadata">

**Author:** ![Zhenhao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zhenhao/32/23177_2.png) [@Zhenhao](https://root-forum.cern.ch/u/Zhenhao)\
**Post date:** [August 25, 2020, 2:07pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/11 "2020-08-25T14:07:46Z")

</div>

It’s

```auto
Version 16.7.2
Windows 10 SDK (10.0.18362.0)

```

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 25, 2020, 2:13pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/12 "2020-08-25T14:13:58Z")

</div>

So no luck, it works for me with the same setup:

```auto
**********************************************************************
** Visual Studio 2019 Developer Command Prompt v16.7.2
** Copyright (c) 2020 Microsoft Corporation
**********************************************************************
[vcvarsall.bat] Environment initialized for: 'x86'

C:\Users\sftnight>Downloads\root\bin\thisroot.bat

C:\Users\sftnight>root
   ------------------------------------------------------------------
  | Welcome to ROOT 6.22/02 https://root.cern |
  | (c) 1995-2020, The ROOT Team; conception: R. Brun, F. Rademakers |
  | Built for win32 on Aug 17 2020, 12:46:52 |
  | From tags/v6-22-02@v6-22-02 |
  | Try '.help', '.demo', '.license', '.credits', '.quit'/'.q' |
   ------------------------------------------------------------------

root [0] gSystem->Load("libGpad.dll")
(int) 0
root [1] std::cout << "kjh " << 12.345 << " " << 12345 << std::endl;
kjh 12.345 12345
root [2]

```

---

<div class="post-metadata">

**Author:** ![Zhenhao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zhenhao/32/23177_2.png) [@Zhenhao](https://root-forum.cern.ch/u/Zhenhao)\
**Post date:** [August 25, 2020, 2:20pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/13 "2020-08-25T14:20:26Z")

</div>

Could you please help me try this two files? I put it here:

[https://1drv.ms/u/s!Ahthsev5X2HBhM463m\_WB6DV8qenoA?e=j3WooS](https://1drv.ms/u/s!Ahthsev5X2HBhM463m_WB6DV8qenoA?e=j3WooS)

If it works, I’ll begin to compile root on windows.~\_~

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 25, 2020, 2:27pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/14 "2020-08-25T14:27:04Z")

</div>

No, it cannot load the dll… Where is this coming from? How was it build?

---

<div class="post-metadata">

**Author:** ![Zhenhao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zhenhao/32/23177_2.png) [@Zhenhao](https://root-forum.cern.ch/u/Zhenhao)\
**Post date:** [August 25, 2020, 2:30pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/15 "2020-08-25T14:30:03Z")

</div>

It’s from here:

> **[SeaBreeze](https://sourceforge.net/projects/seabreeze/)**
>
> Download SeaBreeze for free. Open-source cross-platform spectrometer device driver. SeaBreeze is a device driver library that provides an interface to select Ocean Optics spectrometers. It is written in C/C++ and builds and runs on Windows (XP/7/8),...

  
I just use visual studio 2010 open it and press ‘F7’, it’s build for win32.

I also try `gSystem->Load("libGpad.dll")`. It still causes the problem.

---

<div class="post-metadata">

**Author:** ![Zhenhao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zhenhao/32/23177_2.png) [@Zhenhao](https://root-forum.cern.ch/u/Zhenhao)\
**Post date:** [August 25, 2020, 2:32pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/16 "2020-08-25T14:32:06Z")

</div>

Wait!!! I forgot to delete my rootlogon.C. gSystem-\>Load(“libGpad.dll”) won’t cause the problem!!! So the dll file itself cause the problem!

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 25, 2020, 2:32pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/17 "2020-08-25T14:32:10Z")

</div>

It might be due to different versions of Visual Studio, or unsatisfied dependencies of the `SeaBreeze.dll`. One cannot mix different versions of C++

---

<div class="post-metadata">

**Author:** ![Zhenhao](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/zhenhao/32/23177_2.png) [@Zhenhao](https://root-forum.cern.ch/u/Zhenhao)\
**Post date:** [August 25, 2020, 2:33pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/18 "2020-08-25T14:33:56Z")

</div>

Thank you very much for your help!

Today I reach the maximum number of reply, so I add the update here: I recompile the dll file in VS2019 with option ‘-nostdlib’, and then everything works perfect!

---

<div class="post-metadata">

**Author:** ![bellenot](https://root-forum.cern.ch/user_avatar/root-forum.cern.ch/bellenot/32/29217_2.png) [@bellenot](https://root-forum.cern.ch/u/bellenot)\
**Post date:** [August 25, 2020, 2:34pm UTC](https://root-forum.cern.ch/t/gsystem-load-cause-cout-anything-endl-crash-root-comand-line-on-win10/41134/19 "2020-08-25T14:34:19Z")

</div>

You’re very welcome!
